diff options
Diffstat (limited to 'demo5.html')
-rw-r--r-- | demo5.html | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/demo5.html b/demo5.html new file mode 100644 index 0000000..1e59063 --- /dev/null +++ b/demo5.html @@ -0,0 +1,63 @@ +<html> + <head> + <link rel="stylesheet" href="leaflet/dist/leaflet.css" /> + <script src="leaflet/dist/leaflet-src.js"></script> + + <style> + body { + padding: 0; + margin: 0; + } + + html, body, #map { + height: 100%; + } + </style> + </head> + <body> + <div id="map"> + </div> + + <script> + var artHouseCafe = [50.9087036, -1.4045204]; + + var map = L.map('map', { + center: artHouseCafe, // The Art House Cafe + zoom: 18 + }); + + var tileLayer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { + attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors' + }); + + tileLayer.addTo(map); + + // Load some GeoJSON exported from OpenStreetMap using the OverpassAPI + // (http://overpass-turbo.eu/s/7yI) + + getJSON("cafes.json", function(cafes) { + + L.geoJson(cafes).addTo(map); + }); + + // function to get a JSON file + function getJSON(url, callback) { + var xhttp = new XMLHttpRequest(); + + xhttp.open('GET', url, true); + xhttp.setRequestHeader('Accept', 'application/json'); + + xhttp.onreadystatechange = function() { + if (xhttp.status == 200 && + xhttp.readyState == 4) { + + callback(JSON.parse(xhttp.responseText), xhttp.responseText); + } + }; + + xhttp.send(); + } + + </script> + </body> +</html> |