[OpenLayers-Users] Problem with removeMarker
Linda Rawson
linda.rawson at gmail.com
Sun Mar 16 23:16:30 EDT 2008
Brilliant! Thanks Esteban!
function deleteMarkers() {
var i=0;
var myMarkers = markerLayer.markers;
while (i<myMarkers.length) {
var myMarker = myMarkers[i];
if (myMarker.lonlat.lat == 45) {
markerLayer.removeMarker(myMarker);
} else {
i=i+1;
}
}
}
On Sun, Mar 16, 2008 at 5:32 PM, Esteban olm <esteban.olm at gmail.com> wrote:
> Linda, Your code is weong. You need a WHILE, not a FOR
>
> Your List: 0, 30, 45, 45, 45, 45, 30
>
> An example of iteration in your list:
>
> i=0, List[i]=0 <- don't do anithig
> Your List: 0, 30, 45, 45, 45, 45, 30
>
> i=1, List[i]=30 <- don't do anithig
> Your List: 0, 30, 45, 45, 45, 45, 30
>
> i=2, List[i]=45 <- delete
> Your List: 0, 30, 45, 45, 45, 30
>
> i=3, List[i]=45 <- delete
> Your List: 0, 30, 45, 45, 45, 30
>
> i=4, List[i]=45 <- delete
> Your List: 0, 30, 45, 45, 30
>
> i=5, <- end, out of list
> Total: 3 deletes.
>
> Use a while and an i variable
> i++ when nothing happens
> i no change when delete
>
> 2008/3/16, Eric Lemoine <eric.c2c at gmail.com>:
> >
> >
> >
> > On Sun, Mar 16, 2008 at 6:26 PM, Linda Rawson <linda.rawson at gmail.com>
> wrote:
> > > I have to cycle through the marker layer again and again until all the
> > > markers are gone. What a performance hit!
> >
> >
> > What wouldn't you follow Huub's recommandation?
> > --
> >
> > Eric
> >
> > _______________________________________________
> > Users mailing list
> > Users at openlayers.org
> > http://openlayers.org/mailman/listinfo/users
> >
>
>
--
Linda Rawson
More information about the Users
mailing list