summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2016-02-19 14:04:57 +0100
committerJonas Smedegaard <dr@jones.dk>2016-02-19 14:04:57 +0100
commitdfb7f57776ccc5008dfe4ab892c52b3ed5ca9d6d (patch)
treeb67355a3d0e43c91c8ca66d365d68ab8b5001c51
parentdc1202f762a346bc71938d12ffe94521aae3843e (diff)
Add map template.
-rw-r--r--templates/map.mdwn33
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 = '&copy; <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>