diff --git a/javascript/geoJSON.js b/javascript/geoJSON.js index cc5984a9b2e92e38f34e9b9265d7cebee6ac8f12..d3e45a59f9dc4cbd5b256aa144c6298146cd9809 100644 --- a/javascript/geoJSON.js +++ b/javascript/geoJSON.js @@ -1 +1,18 @@ -L.GeoJSON.AJAX("exampleData/vann_2.geojson").addTo(map); \ No newline at end of file +var rectangle = [{ + "type": "Feature", + "properties": {"name": "Gløshaugen"}, + "geometry": { + "type": "Polygon", + "coordinates": [[ + [10.403787, 63.420031], + [10.410954, 63.414691], + [10.404863, 63.414188], + [10.398170, 63.418901], + [10.403787, 63.420031] + ]] + } +}]; + +var geoLayer = L.geoJSON().addTo(map); + +geoLayer.addData(rectangle); diff --git a/javascript/map.js b/javascript/map.js index bf4e39be48e231607f57a2c6d11ac82851e00547..434a3dc949e4a425cbc7e9608de062980e679c8e 100644 --- a/javascript/map.js +++ b/javascript/map.js @@ -46,3 +46,11 @@ function activateMap() { handler.enable(); }); } + +map.on('click', function() { + if(map.hasLayer(geoLayer)) { + map.removeLayer(geoLayer); + } else { + map.addLayer(geoLayer); + } + });