diff options
Diffstat (limited to 'src/js/app/mapfactory.js')
-rw-r--r-- | src/js/app/mapfactory.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/js/app/mapfactory.js b/src/js/app/mapfactory.js new file mode 100644 index 0000000..8d8bb0e --- /dev/null +++ b/src/js/app/mapfactory.js @@ -0,0 +1,26 @@ +define(['leaflet'], function(L) { + // base config + var attribOSM = '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors', + OSMLayer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: attribOSM + }), + scale = L.control.scale({ + imperial: false + }); + + return function(id, bounds) { + var map = L.map(id, { + layers: [OSMLayer] + }) + if (bounds) { + map.fitBounds(L.latLngBounds(bounds)); + } else { + map.fitWorld().zoomIn(); + } + map.attributionControl.setPrefix(false); + + scale.addTo(map); + + return map; + }; +}); |