Skip to content
Snippets Groups Projects
Commit 49e27836 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Selected coordinate should be displayed in a form when map is opened

parent 7eed3cad
No related branches found
No related tags found
1 merge request!191Add map module and Open-Meteo support
...@@ -9,7 +9,8 @@ import { ...@@ -9,7 +9,8 @@ import {
GeoJSON, GeoJSON,
DomEvent, DomEvent,
Control, Control,
DomUtil DomUtil,
latLng
} from '/js/3rdparty/leaflet-src.esm.js'; } from '/js/3rdparty/leaflet-src.esm.js';
/** /**
...@@ -505,10 +506,27 @@ class MapModal { ...@@ -505,10 +506,27 @@ class MapModal {
this.mapModalElement.style.alignItems = 'center'; this.mapModalElement.style.alignItems = 'center';
this.initMap(latitude, longitude, zoomLevel); this.initMap(latitude, longitude, zoomLevel);
if (selectedPointOfInterestId) { if (selectedPointOfInterestId) {
this.selectPointById(selectedPointOfInterestId); // Id -1 is used if the map should display the single given point as selected, with a form to enable lat/lng modification
if(selectedPointOfInterestId === -1) {
const layer = this.getLayerById(selectedPointOfInterestId)
const feature = this.getFeatureById(selectedPointOfInterestId)
this.map.removeLayer(layer);
this.simulateMapClick(this.map, feature.geometry.coordinates[1], feature.geometry.coordinates[0])
} else {
this.selectPointById(selectedPointOfInterestId);
}
} }
} }
simulateMapClick(map, lat, lng) {
const clickEvent = {
latlng: latLng(lat, lng),
layerPoint: map.latLngToLayerPoint(latLng(lat, lng)),
containerPoint: map.latLngToContainerPoint(latLng(lat, lng))
};
map.fire('click', clickEvent);
}
/** /**
* Hide modal. Remove container element and map. * Hide modal. Remove container element and map.
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment