[OpenLayers-Users] erasing previous markers
Surya Tarigan
surya.tarigan at yahoo.com
Tue Sep 22 10:34:49 EDT 2009
Dear list,
Every time a user choose a location from drop down list, a marker will be constructed on the WMS map by a function
(see snippet below).
To avoid being crowded, how to erase markers created by previous users, before a new user choose a new location?
Any hints would be appreciated.
thank you
kind regards,
surya
---------------------------------------
function go(){
......
var lonlat = document.getElementById('lonlat').options[document.getElementById('lonlat').selectedIndex].value;
var longitude = lonlat.substring(0,lonlat.indexOf(','));
var latitude = lonlat.substring(lonlat.indexOf(',')+1,lonlat.length);
map.setCenter(new OpenLayers.LonLat(longitude,latitude),6);
var markers = new OpenLayers.Layer.Markers ("Markers", {'calculateInRange': function() { return true; }});
var size = new OpenLayers.Size (21, 25);
var offset = new OpenLayers.Pixel (-(size.w/2), -size.h);
var icon1 = new OpenLayers.Icon ('http://localhost:8080/geoserver/openlayers/img/marker-gold.png', size, offset);
m1 = new OpenLayers.Marker (new OpenLayers.LonLat (longitude,latitude), icon1);
m1.setOpacity (1);
markers.addMarker (m1);
}
--------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090922/cc84bec9/attachment.html
More information about the Users
mailing list