diff --git a/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html b/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html index 03f5b297d9c38cdd0c3d0d51030e632dd94686ec..efa1bea5a56c1314a93a4e8b2db23b211b873eb6 100755 --- a/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html +++ b/cerealblotchmodels/templates/cerealblotchmodels/barleynetblotchform.html @@ -211,22 +211,6 @@ inputLatitudeElement.value = selectedLatitude; inputLongitudeElement.value = selectedLongitude; } - - selectedPoint = 1; - selectedFeature = { - "type": "FeatureCollection", "features": [ - { - "type": "Feature", - "geometry": { - "type": "Point", - "coordinates": [selectedLongitude, selectedLatitude] - }, - "properties": { - "pointOfInterestId": selectedPoint, - "pointOfInterestName": coordinatesData.name, - } - }] - }; } function selectPoi(poiData) { @@ -244,6 +228,27 @@ } window.openCoordinatesMap = () => { + if (inputLatitudeElement.value && inputLongitudeElement.value) { + selectedPoint = 1; + selectedFeature = { + "type": "FeatureCollection", "features": [ + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [parseFloat(inputLongitudeElement.value), parseFloat(inputLatitudeElement.value)] + }, + "properties": { + "pointOfInterestId": selectedPoint, + "pointOfInterestName": "Punkt", + } + }] + }; + } else { + selectedPoint = undefined; + selectedFeature = undefined; + } + const coordinatesMapInstance = new MapModal('coordinates-map', {}, selectedFeature, 'nb', true, selectCoordinates); coordinatesMapInstance.openModal(selectedPoint); }