From 4cb9fa18f05cacef38c4c4fed7b563f8dfe583d9 Mon Sep 17 00:00:00 2001
From: Lene Wasskog <lene.wasskog@nibio.no>
Date: Wed, 29 Jan 2025 11:38:12 +0100
Subject: [PATCH] fix: Make map view available to the rest of the script

Fixes bug in which the location of an observation is not displayed on map
---
 .../static/observations/js/observationViewMap.js     | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/observations/static/observations/js/observationViewMap.js b/observations/static/observations/js/observationViewMap.js
index fe708058..a09f5a0a 100755
--- a/observations/static/observations/js/observationViewMap.js
+++ b/observations/static/observations/js/observationViewMap.js
@@ -31,16 +31,18 @@ var initMap = function(geoJSON, poi, container, mapAttribution)
                    })
     });
 	
+	const view = new ol.View({
+		center: ol.proj.fromLonLat([10,65], 'EPSG:3857'),
+		zoom: 7,
+		maxZoom: 7
+	});
+
 	// Creating the map
 	map = new ol.Map({
 			target: container,
 			layers: [backgroundLayer],
 			renderer: 'canvas',
-            view: new ol.View({
-                center: ol.proj.fromLonLat([10,65], 'EPSG:3857'),
-				zoom: 7,
-				maxZoom: 7
-            })
+            view: view
 	});
 	
 	var features = new ol.Collection();
-- 
GitLab