diff options
author | Siri Reiter <siri@jones.dk> | 2018-05-21 20:01:31 +0200 |
---|---|---|
committer | Siri Reiter <siri@jones.dk> | 2018-05-21 20:01:31 +0200 |
commit | 9ef26b7a2e55e1c484760d1e5ad462d824ce6ac1 (patch) | |
tree | 374d1c5237ea32dbf9f1543915d8806520b0561e | |
parent | 22f268b88b91945df80935a142849e90e0a3ddb0 (diff) |
Move region out as GeoJSON data file (for one region).
-rw-r--r-- | src/data/tours.json | 153 | ||||
-rw-r--r-- | src/js/tours.js | 52 |
2 files changed, 167 insertions, 38 deletions
diff --git a/src/data/tours.json b/src/data/tours.json new file mode 100644 index 0000000..3065ac8 --- /dev/null +++ b/src/data/tours.json @@ -0,0 +1,153 @@ +{ + "crs": { + "properties": { + "name": "urn:ogc:def:crs:EPSG::4326" + }, + "type": "name" + }, + "features": [ + { + "geometry": { + "coordinates": [ + [ + [ + 12.56572, + 55.73275 + ], + [ + 12.56692, + 55.73247 + ], + [ + 12.56748, + 55.73054 + ], + [ + 12.56836, + 55.73009 + ], + [ + 12.57631, + 55.72909 + ], + [ + 12.57648, + 55.72954 + ], + [ + 12.57587, + 55.72776 + ], + [ + 12.57769, + 55.72289 + ], + [ + 12.57746, + 55.72165 + ], + [ + 12.58291, + 55.72165 + ], + [ + 12.58621, + 55.71251 + ], + [ + 12.59308, + 55.69607 + ], + [ + 12.59643, + 55.7011 + ], + [ + 12.59359, + 55.6951 + ], + [ + 12.59153, + 55.69916 + ], + [ + 12.5796, + 55.69607 + ], + [ + 12.57136, + 55.69094 + ], + [ + 12.56149, + 55.69621 + ], + [ + 12.56278, + 55.70647 + ], + [ + 12.5584, + 55.70352 + ], + [ + 12.55497, + 55.71009 + ], + [ + 12.55325, + 55.71106 + ], + [ + 12.55879, + 55.71466 + ], + [ + 12.56437, + 55.71913 + ], + [ + 12.56261, + 55.71986 + ], + [ + 12.5613, + 55.71986 + ], + [ + 12.56355, + 55.72191 + ], + [ + 12.56136, + 55.72242 + ], + [ + 12.56162, + 55.72533 + ], + [ + 12.56357, + 55.73127 + ], + [ + 12.56424, + 55.73131 + ], + [ + 12.566, + 55.73124 + ] + ] + ], + "type": "Polygon" + }, + "properties": { + "link": "../../osterbro/", + "linktext": "Ture på Østerbro" + }, + "type": "Feature" + } + ], + "type": "FeatureCollection" +} diff --git a/src/js/tours.js b/src/js/tours.js index 0224d29..7149289 100644 --- a/src/js/tours.js +++ b/src/js/tours.js @@ -4,7 +4,10 @@ requirejs(['./slippymap'], function(_foo) { requirejs.config({ baseUrl: depth + 'js/lib', }); - requirejs(['app/mapfactory'], function(mkmap) { + requirejs([ + 'app/mapfactory', + 'json!data/tours.json' + ], function(mkmap, tours) { L.Icon.Default.imagePath = depth + 'img/leaflet/'; var map = mkmap('map', [ [55.76846, 12.45369], @@ -46,53 +49,26 @@ function highlightFeature(e) { function resetHighlight(e) { geojson.resetStyle(e.target); } +function popup (e) { + var layer = e.target; + return '<a href="'+layer.feature.properties.link+'">'+layer.feature.properties.link+'</a>'; +} function onEachFeature(feature, layer) { layer.on({ + click: popup, mouseover: highlightFeature, mouseout: resetHighlight }); } -var polygon = L.polygon([ - [55.73275, 12.56572], - [55.73247, 12.56692], - [55.73054, 12.56748], - [55.73009, 12.56836], - [55.72909, 12.57631], - [55.72954, 12.57648], - [55.72776, 12.57587], - [55.72289, 12.57769], - [55.72165, 12.57746], - [55.72165, 12.58291], - [55.71251, 12.58621], - [55.69607, 12.59308], - [55.7011, 12.59643], - [55.6951, 12.59359], - [55.69916, 12.59153], - [55.69607, 12.5796], - [55.69094, 12.57136], - [55.69621, 12.56149], - [55.70647, 12.56278], - [55.70352, 12.5584], - [55.71009, 12.55497], - [55.71106, 12.55325], - [55.71466, 12.55879], - [55.71913, 12.56437], - [55.71986, 12.56261], - [55.71986, 12.5613], - [55.72191, 12.56355], - [55.72242, 12.56136], - [55.72533, 12.56162], - [55.73127, 12.56357], - [55.73131, 12.56424], - [55.73124, 12.566] - ]); - -geojson = L.geoJson(polygon.toGeoJSON(), { +geojson = L.geoJson(tours, { style: style, onEachFeature: onEachFeature +//}).bindPopup(function (layer) { +// return '<a href="'+layer.feature.properties.link+'">'+layer.feature.properties.link+'</a>'; }).addTo(map); -geojson.bindPopup("<a href=../../osterbro/>Ture på Østerbro</a>"); +//geojson.bindPopup("<a href=../../osterbro/>Ture på Østerbro</a>"); +//geojson.bindPopup(popup); var polygon = L.polygon([ [55.69916, 12.59171], [55.69505, 12.59359], |