Work on layers UI
This commit is contained in:
parent
75a776a574
commit
10c9ca81c7
8 changed files with 54 additions and 35 deletions
|
@ -61,19 +61,25 @@ $(document).ready(function () {
|
|||
L.control.customZoom({position: 'topright'})
|
||||
.addTo(map);
|
||||
|
||||
L.OSM.layers({position: 'topright', layers: layers})
|
||||
.addTo(map);
|
||||
var uiPane = $('#map-ui')[0];
|
||||
|
||||
L.OSM.layers({
|
||||
position: 'topright',
|
||||
layers: layers,
|
||||
uiPane: uiPane
|
||||
}).addTo(map);
|
||||
|
||||
L.control.share({
|
||||
getUrl: getShortUrl
|
||||
getUrl: getShortUrl,
|
||||
uiPane: uiPane
|
||||
}).addTo(map);
|
||||
|
||||
L.control.note({
|
||||
position: 'topright'
|
||||
position: 'topright'
|
||||
}).addTo(map);
|
||||
|
||||
L.control.locate({
|
||||
position: 'topright'
|
||||
position: 'topright'
|
||||
}).addTo(map);
|
||||
|
||||
L.control.scale().addTo(map);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
L.OSM.Layers = L.Control.extend({
|
||||
onAdd: function (map) {
|
||||
this._map = map;
|
||||
this._initLayout(map);
|
||||
return this._container;
|
||||
},
|
||||
|
@ -14,12 +15,7 @@ L.OSM.Layers = L.Control.extend({
|
|||
link.href = '#';
|
||||
link.title = 'Layers';
|
||||
|
||||
this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
|
||||
|
||||
L.DomEvent
|
||||
.on(this._uiPane, 'click', L.DomEvent.stopPropagation)
|
||||
.on(this._uiPane, 'click', L.DomEvent.preventDefault)
|
||||
.on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
|
||||
this._uiPane = this.options.uiPane;
|
||||
|
||||
$(link).on('click', $.proxy(this.toggleLayers, this));
|
||||
},
|
||||
|
@ -36,7 +32,32 @@ L.OSM.Layers = L.Control.extend({
|
|||
} else {
|
||||
$(this._uiPane)
|
||||
.show()
|
||||
.html(JST["templates/map/layers"]({layers: this.options.layers}));
|
||||
.html(JST["templates/map/layers"]());
|
||||
|
||||
var list = $(this._uiPane).find('.base-layers ul');
|
||||
|
||||
var layers = this.options.layers;
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var item = $('<li></li>')
|
||||
.appendTo(list);
|
||||
|
||||
var div = $('<div></div>')
|
||||
.appendTo(item);
|
||||
|
||||
var map = L.map(div[0], {attributionControl: false, zoomControl: false})
|
||||
.setView(this._map.getCenter(), Math.max(this._map.getZoom() - 2, 0))
|
||||
.addLayer(new layers[i].layer.constructor);
|
||||
|
||||
map.dragging.disable();
|
||||
map.touchZoom.disable();
|
||||
map.doubleClickZoom.disable();
|
||||
map.scrollWheelZoom.disable();
|
||||
|
||||
var label = $('<label></label>')
|
||||
.text(layers[i].name)
|
||||
.appendTo(item);
|
||||
}
|
||||
|
||||
controlContainer.css({paddingRight: '200px'});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,7 @@ L.Control.Share = L.Control.extend({
|
|||
link.href = '#';
|
||||
link.title = this.options.title;
|
||||
|
||||
this._uiPane = L.DomUtil.create('div', 'leaflet-map-ui', map._container);
|
||||
|
||||
L.DomEvent
|
||||
.on(this._uiPane, 'click', L.DomEvent.stopPropagation)
|
||||
.on(this._uiPane, 'click', L.DomEvent.preventDefault)
|
||||
.on(this._uiPane, 'dblclick', L.DomEvent.preventDefault);
|
||||
this._uiPane = this.options.uiPane;
|
||||
|
||||
var h2 = L.DomUtil.create('h2', '', this._uiPane);
|
||||
h2.innerHTML = I18n.t('javascripts.share.title');
|
||||
|
|
|
@ -7,8 +7,5 @@
|
|||
<div class='base-layers'>
|
||||
<p><%= I18n.t('javascripts.map.layers.base') %></p>
|
||||
<ul>
|
||||
<% for (var i = 0; i < layers.length; i++) { %>
|
||||
<label><input type='radio'><%= layers[i].name %></label>
|
||||
<% } %>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -562,20 +562,18 @@ a.donate {
|
|||
margin: 10px;
|
||||
}
|
||||
|
||||
.leaflet-map-ui-layers {
|
||||
box-shadow: 0 1px 7px rgba(0, 0, 0, 0.4);
|
||||
background: #f8f8f9;
|
||||
-webkit-border-radius: 8px;
|
||||
border-radius: 8px;
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
#map-ui {
|
||||
position: absolute;
|
||||
display: none;
|
||||
right: 0;
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
background: white;
|
||||
|
||||
.leaflet-control-layers-separator {
|
||||
margin: 5px -10px !important;
|
||||
.leaflet-container {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
.leaflet-control-attribution {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/*
|
||||
*= require leaflet
|
||||
*= require leaflet.locationfilter
|
||||
*= require map-ui
|
||||
*/
|
||||
|
||||
/* Override to serve images through the asset pipeline. */
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
<div id="map">
|
||||
</div>
|
||||
|
||||
<div id="map-ui">
|
||||
</div>
|
||||
|
||||
<iframe id="linkloader" style="display: none">
|
||||
</iframe>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue