Marker on Google Map added only once.
Posted
by Vafello
on Stack Overflow
See other posts from Stack Overflow
or by Vafello
Published on 2010-03-24T19:34:52Z
Indexed on
2010/03/24
19:43 UTC
Read the original article
Hit count: 257
I have the following code:
function clicked(overlay, latlng) {
var icon3 = new GIcon();
icon3.image = "marker.png";
icon3.iconAnchor = new GPoint(15, 40);
var marker2 = new GMarker(latlng, { icon: icon3, draggable: true, title: 'Drag me' });
map.addOverlay(marker2);
}
Each time I click on the map a new marker is placed on the map. The problem is that I need only one marker and if I click several times, each time a new marker is added. How to change the code so only one marker is placed and when the map is clicked again it just changes its location?
© Stack Overflow or respective owner