X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2119911aa511d7340318367ae2e3c1dc98bcab76..15d148dbd4cb7497f7faae06e58d4227c530cd8a:/app/assets/javascripts/map.js.erb diff --git a/app/assets/javascripts/map.js.erb b/app/assets/javascripts/map.js.erb index 90aefa945..80e77f26c 100644 --- a/app/assets/javascripts/map.js.erb +++ b/app/assets/javascripts/map.js.erb @@ -17,7 +17,7 @@ var layers; var objectLayer; var objectLoader; -function createMap(divName, options) { +function createMap(divName, options, moreOptions) { if (!layers) { layers = [ { @@ -51,6 +51,8 @@ function createMap(divName, options) { ]; } + moreOptions = moreOptions || {}; + options = $.extend({zoomControl: true, panZoomControl: true, layerControl: true}, options); map = L.map(divName, $.extend({}, options, {panControl: false, zoomsliderControl: false, maxZoom: 18})); @@ -59,10 +61,6 @@ function createMap(divName, options) { map.attributionControl.setPrefix(''); } - if (options.panZoomControl) { - new L.Control.Pan().addTo(map); - new L.Control.Zoomslider({stepHeight: 7}).addTo(map); - } var layersControl = L.control.layers(); @@ -71,6 +69,13 @@ function createMap(divName, options) { map.layersControl = layersControl; } + if (moreOptions.locateControl) { + var loc = L.control.locate({ + position: 'topright' + }); + loc.addTo(map); + } + for (var i = 0; i < layers.length; i++) { layers[i].layer = new (layers[i].klass)(layers[i]); layersControl.addBaseLayer(layers[i].layer, layers[i].name);