aboutsummaryrefslogtreecommitdiff
path: root/src/js/app/mapfactory.js
blob: 647ef313cb3cb3a4fa84fa556e7d3823a660e96d (plain)
  1. define(['leaflet'], function(L) {
  2. // base config
  3. var attribOSM = '&copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors';
  4. var attribCarto = '&copy; <a href="https://cartodb.com/attributions">CARTO</a>';
  5. var licenseODbL ='under the <a href="https://opendatacommons.org/licenses/odbl/1.0/">ODbL 1.0</a> license';
  6. var TileLayer = L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png', {
  7. attribution: 'Imagery ' + attribCarto + ' &mdash; Map data ' + attribOSM + ' ' + licenseODbL,
  8. subdomains: 'abcd',
  9. maxZoom: 19
  10. }),
  11. scale = L.control.scale({
  12. imperial: false
  13. });
  14. return function(id, bounds) {
  15. var map = L.map(id, {
  16. layers: [TileLayer]
  17. })
  18. if (bounds) {
  19. map.fitBounds(L.latLngBounds(bounds));
  20. } else {
  21. map.fitWorld().zoomIn();
  22. }
  23. map.attributionControl.setPrefix(false);
  24. scale.addTo(map);
  25. return map;
  26. };
  27. });