0
나는이 example을 적용하여 체크 박스 ID를 기반으로 리플릿 레이어를 필터링하려고했습니다. 활성화 된 객체가 채워지고 해당 지형이 필터링되어지도에 추가되는 일종의 작품입니다.필터 전단지 Geojson 객체는 체크 박스 상태를 기반으로합니다.
그러나 확인란을 선택 취소하면 객체가 비게되지만 지울 지 여부는 아무 것도 없으므로 지형지 물이지도에 남아 있습니다.
기능을 제거하려면 무엇을해야합니까? 스크립트가 귀하의 update()
기능을 실행 할 때마다
function update() {
var enabled = {};
// Run through each checkbox and record whether it is checked. If it is,
// add it to the object of types to display, otherwise do not.
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) enabled[checkboxes[i].id] = true;
}
L.geoJson(parishesData, {
filter: function(feature, layer) {
return (feature.properties.name in enabled);
}
}).addTo(map);
console.log(enabled)
};
큰 덕분 그! 비슷한 것을 시도했지만 매번 L.geoJson 그룹을 제거하지 않았습니다. –