summaryrefslogtreecommitdiff
path: root/src/js/app/mapfactory.js
blob: 4802f50b0e05f91ae54d94d8ac9ec89ef4e262bc (plain)
  1. define(['leaflet'], function(L) {
  2. // base config
  3. var attribOSM = '&copy; <a href="https://www.openstreetmap.org/">OpenStreetMap-bidragydere</a>';
  4. var licenseCcBySa2 = 'under en <a href="https://creativecommons.org/licenses/by-sa/2.0/">Creative Commons Kreditering-DelPåSammeVilkår</a> licens.';
  5. var licenseODbL ='under licensen <a href="https://opendatacommons.org/licenses/odbl/1.0/">ODbL 1.0</a>';
  6. var TileLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  7. attribution: attribOSM + ', kartografi ' + licenseCcBySa2 + ', kortdata ' + licenseODbL
  8. }),
  9. scale = L.control.scale({
  10. imperial: false
  11. });
  12. return function(id, bounds) {
  13. var map = L.map(id, {
  14. layers: [TileLayer]
  15. })
  16. if (bounds) {
  17. map.fitBounds(L.latLngBounds(bounds));
  18. } else {
  19. map.fitWorld().zoomIn();
  20. }
  21. map.attributionControl.setPrefix(false);
  22. scale.addTo(map);
  23. return map;
  24. };
  25. });