i want get api change checkbox no append location group
but when change checkbox and get api location group; append It with the previous group
how to with once change show group location and hidden group location
$("input[name='item-select-id']").change(function () {
if (this.checked) {
var changeId = $(this).val();
fetch('/api/map/' + changeId, { method: 'GET' })
.then(response => response.json())
.then(json => {
areaJson = new L.geoJSON(json, {
style: function (feature) {
return { color: "#fff" };
},
pointToLayer: function (feature, latlng) {
markers.addLayer(L.marker(latlng));
map.addLayer(markers);
//switch (changeId) {
// case "1":
// var aMarker = new L.marker(latlng);
// markers1.addLayer(aMarker);
// map.addLayer(markers1);
// break;
// case "2":
// var anotherMarker = new L.marker(latlng);
// markers2.addLayer(anotherMarker);
// map.addLayer(markers2);
// break;
// default:
// // code block
//}
},
}).addTo(map);
console.log(markers);
}).catch(error => console.log(error.message));
} else {
}
});
Aucun commentaire:
Enregistrer un commentaire