Leaflet label removal after layer removal
After a layer is removed, the
by Strac
HTML
<script src="http://leaflet.cloudmade.com/dist/leaflet.js"></script>
<link rel="stylesheet" href="http://leaflet.cloudmade.com/dist/leaflet.css">
<script src="http://83.86.72.74/leaflet/leaflet.label.js"></script>
<link rel="stylesheet" href="http://83.86.72.74/leaflet/leaflet.label.css">
<script src="http://83.86.72.74/js/test.js"></script>
<div id="map" style="height:600px; width:600px"></div>
JavaScript
var Main_RegionLayer;
var map = L.map('map').setView([52.1, 5.2], 13);
var tile = L.tileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
maxZoom: 18
}).addTo(map);
Main_RegionLayer = L.geoJson([]);
function onEachFeature(feature, layer) {
layer.bindLabel(feature.properties.label);
}
function reloadJson() {
Main_RegionLayer.clearLayers();
Main_RegionLayer = L.geoJson([example], {
style: function(feature) {
return feature.properties && feature.properties.style;
},
onEachFeature: onEachFeature
}).addTo(map);
}
map.on('moveend', function(e) {
reloadJson();
});
reloadJson();