Browse Source

Handling circle and radius

pull/1/head
Wahyu Ramadhan 1 year ago
parent
commit
f3db3dac8c
  1. 17
      edit-mode/function/activityLocation.js

17
edit-mode/function/activityLocation.js

@ -43,6 +43,9 @@ function updateCurrentGeoJson() {
let shapes = []; let shapes = [];
drawnItems.eachLayer(function (layer) { drawnItems.eachLayer(function (layer) {
let geojson = layer.toGeoJSON(); let geojson = layer.toGeoJSON();
if (layer instanceof L.Circle) {
geojson.properties.radius = layer.getRadius();
}
shapes.push(geojson); shapes.push(geojson);
}); });
currentGeoJson = { currentGeoJson = {
@ -70,7 +73,15 @@ function openActivityMap(id)
let lGeoJson = L.geoJSON(feature); let lGeoJson = L.geoJSON(feature);
let layers = lGeoJson.getLayers(); let layers = lGeoJson.getLayers();
layers.forEach(layer => { 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 { } else {
@ -285,15 +296,13 @@ function submitCircle(radius)
let geojsoncircle = circle.toGeoJSON(); let geojsoncircle = circle.toGeoJSON();
geojsoncircle.properties.radius = radius geojsoncircle.properties.radius = radius
currentGeoJson = geojsoncircle currentGeoJson = geojsoncircle
// console.log("geojsoncircle", geojsoncircle);
addDrawnLayer(circle); addDrawnLayer(circle);
updateCurrentGeoJson();
map.addControl(drawnControlEdit); map.addControl(drawnControlEdit);
$("#modal_radius").modal('hide'); $("#modal_radius").modal('hide');
} }
$('#modal_radius').on('hide.bs.modal', function (event) { $('#modal_radius').on('hide.bs.modal', function (event) {
circLat = 0
circLong = 0
$("#buffer_radius").val(""); $("#buffer_radius").val("");
}); });
Loading…
Cancel
Save