[dev-italia] Cancellare Markes

Carlo Zardetto carlo a artmediastudio.com
Mer 6 Nov 2013 15:38:29 UTC


Salve ho un problema nella cancellazione dei markers.

Popolo la mappa tramite una chiamata json

myLayer = L.geoJson(url,{
            onEachFeature:function onEachFeature(feature, layer) {
                            //alert(feature.properties.icon.iconUrl);
                            ico=L.icon({iconUrl:feature.properties.icon.iconUrl, iconSize:[20,20],iconAnchor:[10,0]});
                if (feature.geometry.type!="Point")
                {
                    obj=$.geo.centroid(feature.geometry);
                    layer=L.marker(L.latLng(obj.coordinates[1],obj.coordinates[0]), {icon:ico});
                }
                
                if (feature.properties && feature.properties.name) {
            //        layer.bindPopup(feature.properties.name+"<br/><a href='http://www.openstreetmap.org/browse/"+feature.properties["@type"]+"/"+feature.properties["@id"]+"'>Guarda su OSM</a>");
                        layer.bindPopup(feature.properties.name+"<br/>");
                }
            },
            pointToLayer: function (feature, latlng) {        
                var marker=L.marker(latlng, {icon:ico});
                return marker;
            }
        }).addTo(map);

quindi pensavo che con un

myLayer.markerLayer.clearLayers(); oppure myLayer.clearLayers();
mi da errore
map.markerLayer.clearLayers();
non fa nulla.

le due variabili map e myLayer le ho dichiarate a livello globale infatti .

Qualcuno mi puņ dare una mano ?
Grazie

-------------- parte successiva --------------
Un allegato HTML č stato rimosso...
URL: <http://lists.openstreetmap.org/pipermail/dev-italia/attachments/20131106/96d06e1e/attachment.html>


Maggiori informazioni sulla lista dev-italia