From 4ebce383384644e45b5ac21d4d491736f929d34a Mon Sep 17 00:00:00 2001
From: jshjelse <jshjelse@stud.ntnu.no>
Date: Wed, 20 Sep 2023 19:25:43 +0200
Subject: [PATCH] =?UTF-8?q?Forel=C3=B8pig=20ferdigstilling?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 javascript/geoJSON.js | 19 ++++++++++++++++++-
 javascript/map.js     |  8 ++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/javascript/geoJSON.js b/javascript/geoJSON.js
index cc5984a..d3e45a5 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 bf4e39b..434a3dc 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);
+    }
+  });
-- 
GitLab