diff options
author | Jonas Smedegaard <dr@jones.dk> | 2015-09-09 03:25:56 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2015-09-09 03:25:56 +0200 |
commit | f67705f4c95eb75b3aa0bf7cbe2b5175a9644a59 (patch) | |
tree | bbe58c602e373aca3b311e876debe7d7f1e4abd8 |
Initial draft.
-rw-r--r-- | EventListener.js | 125 | ||||
-rw-r--r-- | data.json | 757 | ||||
-rwxr-xr-x | fetch-waypoints | 4 | ||||
-rw-r--r-- | index.html | 21 | ||||
-rw-r--r-- | json-minified.js | 4 | ||||
-rw-r--r-- | map.js | 176 | ||||
-rwxr-xr-x | poi2geojson | 14 | ||||
-rw-r--r-- | yepnope.min.js | 2 |
8 files changed, 1103 insertions, 0 deletions
diff --git a/EventListener.js b/EventListener.js new file mode 100644 index 0000000..fa3423b --- /dev/null +++ b/EventListener.js @@ -0,0 +1,125 @@ +// EventListener | MIT/GPL2 | github.com/jonathantneal/EventListener + +this.Element && Element.prototype.attachEvent && !Element.prototype.addEventListener && (function () { + function addToPrototype(name, method) { + Window.prototype[name] = HTMLDocument.prototype[name] = Element.prototype[name] = method; + } + + // add + addToPrototype("addEventListener", function (type, listener) { + var + target = this, + listeners = target.addEventListener.listeners = target.addEventListener.listeners || {}, + typeListeners = listeners[type] = listeners[type] || []; + + // if no events exist, attach the listener + if (!typeListeners.length) { + target.attachEvent("on" + type, typeListeners.event = function (event) { + var documentElement = target.document && target.document.documentElement || target.documentElement || { scrollLeft: 0, scrollTop: 0 }; + + // polyfill w3c properties and methods + event.currentTarget = target; + event.pageX = event.clientX + documentElement.scrollLeft; + event.pageY = event.clientY + documentElement.scrollTop; + event.preventDefault = function () { event.returnValue = false }; + event.relatedTarget = event.fromElement || null; + event.stopImmediatePropagation = function () { immediatePropagation = false; event.cancelBubble = true }; + event.stopPropagation = function () { event.cancelBubble = true }; + event.target = event.srcElement || target; + event.timeStamp = +new Date; + + // create an cached list of the master events list (to protect this loop from breaking when an event is removed) + for (var i = 0, typeListenersCache = [].concat(typeListeners), typeListenerCache, immediatePropagation = true; immediatePropagation && (typeListenerCache = typeListenersCache[i]); ++i) { + // check to see if the cached event still exists in the master events list + for (var ii = 0, typeListener; typeListener = typeListeners[ii]; ++ii) { + if (typeListener == typeListenerCache) { + typeListener.call(target, event); + + break; + } + } + } + }); + } + + // add the event to the master event list + typeListeners.push(listener); + }); + + // remove + addToPrototype("removeEventListener", function (type, listener) { + var + target = this, + listeners = target.addEventListener.listeners = target.addEventListener.listeners || {}, + typeListeners = listeners[type] = listeners[type] || []; + + // remove the newest matching event from the master event list + for (var i = typeListeners.length - 1, typeListener; typeListener = typeListeners[i]; --i) { + if (typeListener == listener) { + typeListeners.splice(i, 1); + + break; + } + } + + // if no events exist, detach the listener + if (!typeListeners.length && typeListeners.event) { + target.detachEvent("on" + type, typeListeners.event); + } + }); + + // dispatch + addToPrototype("dispatchEvent", function (eventObject) { + var + target = this, + type = eventObject.type, + listeners = target.addEventListener.listeners = target.addEventListener.listeners || {}, + typeListeners = listeners[type] = listeners[type] || []; + + try { + return target.fireEvent("on" + type, eventObject); + } catch (error) { + if (typeListeners.event) { + typeListeners.event(eventObject); + } + + return; + } + }); + + // CustomEvent + Object.defineProperty(Window.prototype, "CustomEvent", { + get: function () { + var self = this; + + return function CustomEvent(type, eventInitDict) { + var event = self.document.createEventObject(), key; + + event.type = type; + for (key in eventInitDict) { + if (key == 'cancelable'){ + event.returnValue = !eventInitDict.cancelable; + } else if (key == 'bubbles'){ + event.cancelBubble = !eventInitDict.bubbles; + } else if (key == 'detail'){ + event.detail = eventInitDict.detail; + } + } + return event; + }; + } + }); + + // ready + function ready(event) { + if (ready.interval && document.body) { + ready.interval = clearInterval(ready.interval); + + document.dispatchEvent(new CustomEvent("DOMContentLoaded")); + } + } + + ready.interval = setInterval(ready, 1); + + window.addEventListener("load", ready); +})(); diff --git a/data.json b/data.json new file mode 100644 index 0000000..3616a35 --- /dev/null +++ b/data.json @@ -0,0 +1,757 @@ +[ + { + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.1880041, + 55.6149996 + ] + }, + "properties": { + "type": "diploma-aspiring", + "title": "Aiah Noack", + "location": "Stærkendevej, 2640 Hedehusene, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.2613603, + 55.9458194 + ] + }, + "properties": { + "type": "member", + "title": "Aiah Noack", + "location": "Vipstjertvej 5, 3400 Hillerød, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.393148, + 54.936405 + ] + }, + "properties": { + "type": "diploma-aspiring", + "title": "Anne Moloney", + "location": "Storemosevej 32, 4944 Fejø, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.2236991, + 55.5372055 + ] + }, + "properties": { + "type": "member", + "title": "Annett Levy Andersen", + "location": "Vestre Strandvej 20, 2680 Solrod Strand, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.2938079, + 55.2526839 + ] + }, + "properties": { + "type": null, + "title": "Annette Brown Nielsen", + "location": "Jernbanevej 9, 4230 Skælskør, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.7125854, + 55.5427375 + ] + }, + "properties": { + "type": "member", + "title": "Astrid Fogh", + "location": "Rødkjærsvej 6, 7000 Fredericia, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.3061671, + 56.3101308 + ] + }, + "properties": { + "type": null, + "title": "Birgitte Kaae", + "location": "Vibevej 28, 8543 Hornslet, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.542088561377, + 55.693261780435 + ] + }, + "properties": { + "type": "center", + "title": "Byhaven 2200", + "location": "Nørrebroparken, Stefansgade 28-30, 2200 København N, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.533963, + 55.729547 + ] + }, + "properties": { + "type": "member", + "title": "Candela Vargas Poveda", + "location": "Sønderdalen 58, 2870 Dyssegård, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.8019105, + 55.7691024 + ] + }, + "properties": { + "type": "diploma", + "title": "Cathrine Dolleris", + "location": "Kattekærstrædet 8, 4300 Holbæk, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.8019105, + 55.7691024 + ] + }, + "properties": { + "type": "member", + "title": "Cathrine Dolleris", + "location": "Kattekærstrædet 8, 4300 Holbæk, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.960858, + 55.787267 + ] + }, + "properties": { + "type": "member", + "title": "Esben Schultz", + "location": "Kyndbyvej 4, 3630 Jaegerspris, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.3975991, + 54.9329371 + ] + }, + "properties": { + "type": "center", + "title": "Fejø Retreat", + "location": "Storemosevej 44, 4944 Fejø, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.0304513, + 56.4692848 + ] + }, + "properties": { + "type": null, + "title": "Frands Frydendal", + "location": "Rådmands Boulevard 8, 8900 Randers C, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.100926, + 57.196382 + ] + }, + "properties": { + "type": null, + "title": "Gitte Fruensgaard Møller", + "location": "Smedegårdsvej 6, 9320 Hjallerup, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.610213, + 55.666291 + ] + }, + "properties": { + "type": "member", + "title": "Heidi Durhuus", + "location": "Holmbladsgade 63B, 2300 København S, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.88442, + 55.871365 + ] + }, + "properties": { + "type": "member", + "title": "Helle Christine Koldkjær", + "location": "Pilegade 22, 8700 Horsens, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.1917194, + 55.6396146 + ] + }, + "properties": { + "type": "member", + "title": "Henning\t& Lieske\tHervik", + "location": "Frankerupvej 3, 4400 Kalundborg, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.6606107, + 55.8713474 + ] + }, + "properties": { + "type": "center", + "title": "Inspiratoriet", + "location": "Sildeballe 17, 8305 Samsø, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.3122920000001, + 55.617559 + ] + }, + "properties": { + "type": "diploma", + "title": "Jesper Saxgren", + "location": "6040 Egtved, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.9328939, + 55.283415 + ] + }, + "properties": { + "type": "member", + "title": "Jette Møller", + "location": "Lundagervej 22, 5610 Assens, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.1179542, + 56.1704192 + ] + }, + "properties": { + "type": "member", + "title": "Johan Herman Weber", + "location": "Spobjergvej 62, 8220 Brabrand, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.053983, + 55.638378 + ] + }, + "properties": { + "type": "member", + "title": "Karen Ingrid Schultz", + "location": "Låddenhøj 65, 4000 Roskilde County, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 14.831842, + 55.110056 + ] + }, + "properties": { + "type": "center", + "title": "Karensminde", + "location": "Skovgårdsvejen 8, 3700 Rønne, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.0639339, + 55.4421259 + ] + }, + "properties": { + "type": "member", + "title": "Kenn Birger Klinthøj", + "location": "Tuemosevej 9, 4632 Bjæverskov, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.9577162, + 55.4090694 + ] + }, + "properties": { + "type": null, + "title": "Kirsten Hess", + "location": "Nyvangsvej 83, 4100 Ringsted, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.659643, + 55.868789 + ] + }, + "properties": { + "type": "center-begin", + "title": "Klejstruplund", + "location": "Sildeballe 7, 8305 Samsø, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 14.831842, + 55.110056 + ] + }, + "properties": { + "type": "diploma-aspiring", + "title": "Kurt Holm", + "location": "Skovgårdsvejen 8, 3700 Rønne, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.554353, + 55.811169 + ] + }, + "properties": { + "type": "center", + "title": "Kærbakkens Permahave - Birgit Rothmann", + "location": "Kærbakken 11, 8305 Samsø Municipality, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 8.852155, + 55.640782 + ] + }, + "properties": { + "type": "member", + "title": "Lasse Thomsen", + "location": "Hovborgvej 99, 7200 Grindsted, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.4967012, + 55.2057518 + ] + }, + "properties": { + "type": "member", + "title": "Leif Varmark\t& Brita Jørgensen", + "location": "Bisserup Havnevej 9, 4243 Rude, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.951299, + 55.792091 + ] + }, + "properties": { + "type": "center-begin", + "title": "Lev Bæredygtigt", + "location": "Solbakkevej 18, 3630 Jægerspris, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.8178749, + 55.4955207 + ] + }, + "properties": { + "type": "member", + "title": "Line Frederiksen", + "location": "Hallingebjergvej 18, 4100 Ringsted, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.7720179, + 56.303925 + ] + }, + "properties": { + "type": null, + "title": "Mette Kjær", + "location": "Rosmus Bygade 14, 8444 Balle, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.5616727, + 55.6908951 + ] + }, + "properties": { + "type": "member", + "title": "Miljøpunkt Nørrebro", + "location": "Blegdamsvej 4, 2200 København N, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 11.944564, + 55.78382 + ] + }, + "properties": { + "type": "diploma", + "title": "Mira Illeris og Esben Schultz", + "location": "Svanholm Alle 1, 4050 Skibby, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.275226, + 54.92288 + ] + }, + "properties": { + "type": "member", + "title": "Morten Dall", + "location": "Søbygårdsmarksvej 3, 5985 Søby Ærø, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 14.858517, + 55.200877 + ] + }, + "properties": { + "type": null, + "title": "Morten Søfting", + "location": "Krashavevej 34, 3760 Gudhjem, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.209834, + 55.6121114 + ] + }, + "properties": { + "type": "center", + "title": "Naturplanteskolen", + "location": "Stærkendevej 177, 2640 Hedehusene, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.819395, + 56.110274 + ] + }, + "properties": { + "type": "member", + "title": "Ole, Annette og Valdemar\tKjærulff\tDavidsen", + "location": "Ravnsøvej 24, 8680 Ry, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.5867677, + 56.2805839 + ] + }, + "properties": { + "type": "center", + "title": "Permakulturhaven Myrrhis", + "location": "Friland 30, Nationalpark Mols Bjerge, 8410 Ronde, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 9.8955546, + 57.4533727 + ] + }, + "properties": { + "type": "member", + "title": "Peter Yde", + "location": "Stensgårdsvej 17, 9800 Hjørring, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.42674, + 55.098561 + ] + }, + "properties": { + "type": "member", + "title": "Pia Duus\tJensen", + "location": "Højgårdsvej 27, 5762 Vester Skerninge, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.557453154523, + 55.698017849107 + ] + }, + "properties": { + "type": "diploma", + "title": "Poul Erik Pedersen", + "location": "Tjørnegade 4, 2200 København N, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.557192, + 55.68961 + ] + }, + "properties": { + "type": "member", + "title": "Sandra Villumsen", + "location": "Nørrebrogade 44A, 2200 København N, Denmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.188499, + 55.361535 + ] + }, + "properties": { + "type": "diploma-aspiring", + "title": "Simon Cazalis", + "location": "Kirkevej 43, 5690 Tommerup, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 12.567535, + 55.709639 + ] + }, + "properties": { + "type": "diploma", + "title": "Tony Andersen", + "location": "Ourøgade 34, 2100 København Ø, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.584405, + 56.281604 + ] + }, + "properties": { + "type": "member", + "title": "Tove Bang - Livets Skole", + "location": "Friland 11, Nationalpark Mols Bjerge, 8410 Rønde, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.275226, + 54.92288 + ] + }, + "properties": { + "type": "center", + "title": "Vitsøhus", + "location": "Søbygårdsmarksvej 3, 5985 Søby Ærø, Danmark" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [ + 10.658894, + 55.218173 + ] + }, + "properties": { + "type": "member", + "title": "Øko-byg", + "location": "Lamdrupvej 20, 5854 Gislev, Danmark" + } + } + ] + } +] diff --git a/fetch-waypoints b/fetch-waypoints new file mode 100755 index 0000000..64d83ff --- /dev/null +++ b/fetch-waypoints @@ -0,0 +1,4 @@ +#!/bin/sh + +curl --data-raw "action=mapp_query&name=mapp0" \ + http://permakultur-danmark.dk/wp-admin/admin-ajax.php diff --git a/index.html b/index.html new file mode 100644 index 0000000..ec3468f --- /dev/null +++ b/index.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> +<head> +<meta charset=utf-8 /> +<title>LAND kort</title> +<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> +<script src="yepnope.min.js" type="text/javascript"></script> +<link href="/usr/share/javascript/leaflet/leaflet.css" rel="stylesheet" type="text/css" /> +<link href="data.json" rel="points" type="application/json"> +<style> + body { margin:0; padding:0; } + #content { position:absolute; top:0; bottom:0; width:100%; } + .leaflet-control-scale { text-align: center; } +</style> +</head> +<body> +<div id="content"></div> +<script src="/usr/share/javascript/leaflet/leaflet.js" type="text/javascript"></script> +<script src="map.js" type="text/javascript"></script> +</body> +</html> diff --git a/json-minified.js b/json-minified.js new file mode 100644 index 0000000..a92138c --- /dev/null +++ b/json-minified.js @@ -0,0 +1,4 @@ +window.jsonParse=function(){var r="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",k='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';k='(?:"'+k+'*")';var s=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+r+"|"+k+")","g"),t=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),u={'"':'"',"/":"/","\\":"\\",b:"\u0008",f:"\u000c",n:"\n",r:"\r",t:"\t"};function v(h,j,e){return j?u[j]:String.fromCharCode(parseInt(e,16))}var w=new String(""),x=Object.hasOwnProperty;return function(h, +j){h=h.match(s);var e,c=h[0],l=false;if("{"===c)e={};else if("["===c)e=[];else{e=[];l=true}for(var b,d=[e],m=1-l,y=h.length;m<y;++m){c=h[m];var a;switch(c.charCodeAt(0)){default:a=d[0];a[b||a.length]=+c;b=void 0;break;case 34:c=c.substring(1,c.length-1);if(c.indexOf("\\")!==-1)c=c.replace(t,v);a=d[0];if(!b)if(a instanceof Array)b=a.length;else{b=c||w;break}a[b]=c;b=void 0;break;case 91:a=d[0];d.unshift(a[b||a.length]=[]);b=void 0;break;case 93:d.shift();break;case 102:a=d[0];a[b||a.length]=false; +b=void 0;break;case 110:a=d[0];a[b||a.length]=null;b=void 0;break;case 116:a=d[0];a[b||a.length]=true;b=void 0;break;case 123:a=d[0];d.unshift(a[b||a.length]={});b=void 0;break;case 125:d.shift();break}}if(l){if(d.length!==1)throw new Error;e=e[0]}else if(d.length)throw new Error;if(j){var p=function(n,o){var f=n[o];if(f&&typeof f==="object"){var i=null;for(var g in f)if(x.call(f,g)&&f!==n){var q=p(f,g);if(q!==void 0)f[g]=q;else{i||(i=[]);i.push(g)}}if(i)for(g=i.length;--g>=0;)delete f[i[g]]}return j.call(n, +o,f)};e=p({"":e},"")}return e}}(); @@ -0,0 +1,176 @@ +var map = null; //global map object + +// base config +var attribOSM = '© <a href="//openstreetmap.org">OpenStreetMap</a>-bidragydere, <a href="//creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'; +var OSMLayer = L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: attribOSM } ); +var Box = L.latLngBounds( [[54.5, 8.0],[57.8, 15.3]] ); + +// GeoJSON feature styling and grouping +function returnFeatureMarker(feature, latlng) { + var hasPopup = (feature.properties.location && feature.properties.type); + return L.marker(latlng, { + title: feature.properties.title, + zIndexOffset: 1000*feature.properties.priority || 0, + clickable: hasPopup, + keyboard: hasPopup + }); +}; +function addFeaturePopup(feature, layer) { + if (feature.properties.location && feature.properties.title) { + layer.bindPopup('<strong>'+feature.properties.title+'</strong><br>'+feature.properties.location); + } +}; +var center = L.geoJson([],{ + pointToLayer: returnFeatureMarker, + onEachFeature: addFeaturePopup, + filter: function(feature, layer) { + return (feature.properties.type == "center"); + } +}); +var center_begin = L.geoJson([],{ + pointToLayer: returnFeatureMarker, + onEachFeature: addFeaturePopup, + filter: function(feature, layer) { + return (feature.properties.type == "center-begin"); + } +}); +var member = L.geoJson([],{ + pointToLayer: returnFeatureMarker, + onEachFeature: addFeaturePopup, + filter: function(feature, layer) { + return (feature.properties.type == "member"); + } +}); +var diploma = L.geoJson([],{ + pointToLayer: returnFeatureMarker, + onEachFeature: addFeaturePopup, + filter: function(feature, layer) { + return (feature.properties.type == "diploma"); + } +}); +var diploma_aspiring = L.geoJson([],{ + pointToLayer: returnFeatureMarker, + onEachFeature: addFeaturePopup, + filter: function(feature, layer) { + return (feature.properties.type == "diploma-aspiring"); + } +}); +var unknown = L.geoJson([],{ + pointToLayer: returnFeatureMarker, + onEachFeature: addFeaturePopup, + filter: function(feature, layer) { + return (feature.properties.type == null); + } +}); +var overlayMaps = { + "LAND Centre": center, + "LAND startere": center_begin, + "Medlemmer": member, + "Diplomholdere": diploma, + "Diplomaspiranter": diploma_aspiring, + "Øvrige": unknown +}; +function overlayCallback(data) { + center.addData(data).addTo(map); + center_begin.addData(data).addTo(map); + member.addData(data).addTo(map); + diploma.addData(data).addTo(map); + diploma_aspiring.addData(data).addTo(map); + unknown.addData(data); +}; + +// position popup +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); +} + +// http://mathiasbynens.be/notes/xhr-responsetype-json +var getJSON = function(url, successHandler, errorHandler) { + var xhr = typeof XMLHttpRequest != 'undefined' + ? new XMLHttpRequest() + : new ActiveXObject('Microsoft.XMLHTTP'); + var supportsJSON = (function() { + if (typeof XMLHttpRequest == 'undefined') { + return false; + } + xhr.open('get', '/', true); + try { + // some browsers throw when setting `responseType` to an unsupported value + xhr.responseType = 'json'; + } catch(error) { + return false; + } + return 'response' in xhr && xhr.responseType == 'json'; + }()); + xhr.open('get', url, true); + if (supportsJSON) { + xhr.responseType = 'json'; + } + xhr.onreadystatechange = function() { + var status; + var data; + // http://xhr.spec.whatwg.org/#dom-xmlhttprequest-readystate + if (xhr.readyState == 4) { // `DONE` + status = xhr.status; + if (status == 200) { + successHandler && successHandler( + supportsJSON + ? xhr.response + : JSON.parse(xhr.responseText) + ); + } else { + errorHandler && errorHandler(status); + } + } + }; + xhr.send(); +}; + +// create base map when DOM is ready, and then add features and controls +function initMap() { + map = L.map('content', { layers: [OSMLayer] }); + map.attributionControl.setPrefix(false); + map.fitBounds(Box); + + // micro-polyfill - http://mathiasbynens.be/notes/document-head + var head = document.head || document.getElementsByTagName('head')[0]; + + // load all rel=points links in html header as GeoJSON + var links = head.getElementsByTagName("link") + for (i=0;i< links.length;i++) { + if (links[i].rel == "points") { + getJSON(links[i].href, function (data) { + overlayCallback(data); + }); + } + }; + + L.control.layers([],overlayMaps).addTo(map); + L.control.scale({ imperial: false }).addTo(map); + + map.on('contextmenu', positionPopup); +}; +yepnope([ + { + test : window.JSON, +// https://code.google.com/p/json-sans-eval/ +// (json2: less secure; json3: larger - unneeded features) + nope : 'json-minified.js', + }, { + test: document.addEventListener, + nope: 'EventListener.js', + complete: function() { + document.addEventListener("DOMContentLoaded", initMap, false) + } + } +]); diff --git a/poi2geojson b/poi2geojson new file mode 100755 index 0000000..7bd808a --- /dev/null +++ b/poi2geojson @@ -0,0 +1,14 @@ +#!/bin/sh + +jq "$@" '[{type: "FeatureCollection", features: [.data.pois[] | { + type: "Feature", + geometry: {type: "Point", coordinates: [.point.lng, .point.lat]}, + properties: {type: ( + if .iconid == "green-dot" then "center" + elif .iconid == "green" then "center-begin" + elif .iconid == "yellow-dot" then "member" + elif .iconid == "pink-dot" then "diploma" + elif .iconid == "ltblue-dot" then "diploma-aspiring" + else null end + ), title: .title, location: .address} +}]}]' diff --git a/yepnope.min.js b/yepnope.min.js new file mode 100644 index 0000000..e05f34a --- /dev/null +++ b/yepnope.min.js @@ -0,0 +1,2 @@ +/*yepnope1.5.4|WTFPL*/ +(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}})(this,document);
\ No newline at end of file |