diff options
-rw-r--r-- | templates/map.mdwn | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/templates/map.mdwn b/templates/map.mdwn new file mode 100644 index 00000000..4f3c3c05 --- /dev/null +++ b/templates/map.mdwn @@ -0,0 +1,33 @@ +[[!meta stylesheet=map rel="stylesheet"]] + +<div id="map"></div> +<script src="/usr/share/javascript/leaflet/leaflet.js"></script> +<script> +var attribOSM = '© <a href="https://openstreetmap.org">OpenStreetMap</a>-bidragydere, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'; +var OSMLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: attribOSM } ); +var Box = L.latLngBounds( [[<TMPL_VAR bounds-nw>],[<TMPL_VAR bounds-se>]] ); + +map = L.map('content', { layers: [OSMLayer] }); +map.attributionControl.setPrefix(false); +map.fitBounds(Box); + +L.control.layers([],overlayMaps).addTo(map); +L.control.scale({ imperial: false }).addTo(map); + +<TMPL_IF positionpopup> +function round(n,d) { + return Math.round(Math.pow(10,d)*n)/Math.pow(10,d) +}; +function lngLatString(latLng) { + return round(latLng.lng,5) + ", " + round(latLng.lat,5) +}; +var popup = L.popup(); +function positionPopup(e) { + popup + .setLatLng(e.latlng) + .setContent("Position (long, lat):<br>" + lngLatString(e.latlng)) + .openOn(map); +} +map.on('contextmenu', positionPopup); +</TMPL_IF> +</script> |