diff --git a/edit-mode/function/activityLocation.js b/edit-mode/function/activityLocation.js index dc6dbca..caaf8a0 100644 --- a/edit-mode/function/activityLocation.js +++ b/edit-mode/function/activityLocation.js @@ -43,6 +43,9 @@ function updateCurrentGeoJson() { let shapes = []; drawnItems.eachLayer(function (layer) { let geojson = layer.toGeoJSON(); + if (layer instanceof L.Circle) { + geojson.properties.radius = layer.getRadius(); + } shapes.push(geojson); }); currentGeoJson = { @@ -70,7 +73,15 @@ function openActivityMap(id) let lGeoJson = L.geoJSON(feature); let layers = lGeoJson.getLayers(); layers.forEach(layer => { - addDrawnLayer(layer) + let radius = layer.feature.properties.radius; + if (radius) { + let latlon = layer.getLatLng(); + let circle = L.circle([latlon.lat, latlon.lng], {radius: radius}); + addDrawnLayer(circle); + } + else { + addDrawnLayer(layer) + } }); }); } else { @@ -285,15 +296,13 @@ function submitCircle(radius) let geojsoncircle = circle.toGeoJSON(); geojsoncircle.properties.radius = radius currentGeoJson = geojsoncircle - // console.log("geojsoncircle", geojsoncircle); addDrawnLayer(circle); + updateCurrentGeoJson(); map.addControl(drawnControlEdit); $("#modal_radius").modal('hide'); } $('#modal_radius').on('hide.bs.modal', function (event) { - circLat = 0 - circLong = 0 $("#buffer_radius").val(""); }); \ No newline at end of file