Remove marker

2,671 views
Skip to first unread message

Andrewc

unread,
Jul 18, 2009, 9:01:44 AM7/18/09
to Google Maps JavaScript API v3
I want the user to select their location..

This sample from Google is perfect for my use:
http://code.google.com/apis/maps/documentation/v3/examples/event-arguments.html

Their can only be 1 location selected, so when a users clicks for a
second time on the map the previous marker should be removed.

How would I get the Lat and long coordinates?

Esa

unread,
Jul 18, 2009, 1:48:25 PM7/18/09
to Google Maps JavaScript API v3

Seo

unread,
Jul 24, 2009, 9:24:20 AM7/24/09
to Google Maps JavaScript API v3
Hi there,

I am also looking for a solution to remove markers, as the function
set_map(null) as describe in de documents does not seem to work.

"To remove a marker, call the set_map() method passing null as the
argument."

http://code.google.com/intl/nl/apis/maps/documentation/v3/overlays.html

This does not work for me.

<script>
if (street_marker) {
street_marker.set_map(null);
}
</script>

The marker will remain on the map, and the old V2 function does not
work anymore.

Anyone got an idea how to remove markers in V3 ?

Christoph Beckmann

unread,
Jul 24, 2009, 9:29:37 AM7/24/09
to google-map...@googlegroups.com
Hi,

look here:
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/2b6baf9e6e2a440d?hl=en

In the future I will publish a library.

Christoph

Seo

unread,
Jul 24, 2009, 9:32:48 AM7/24/09
to Google Maps JavaScript API v3
Seems it did work, however, the info window wasn't automaticly closed
by removing the marker.

Christoph Beckmann

unread,
Jul 24, 2009, 9:44:47 AM7/24/09
to google-map...@googlegroups.com
Hi,

use global "infowindow" variable and execute the close() method from InfoWindow.
http://code.google.com/intl/de-DE/apis/maps/documentation/v3/reference.html#InfoWindow

Look at my little lib sample:
file:///C:/Dokumente%20und%20Einstellungen/Christoph%20Beckmann/Desktop/markerPlugin.html

Christoph

Christoph Beckmann

unread,
Jul 24, 2009, 9:47:32 AM7/24/09
to google-map...@googlegroups.com
sry, I opine/mean this path:
http://www.lootogo.com/googlemapsapi3/markerPlugin.html
 :-)
Christoph

Esa

unread,
Jul 24, 2009, 10:04:54 AM7/24/09
to Google Maps JavaScript API v3


On Jul 24, 4:32 pm, Seo <seo...@gmail.com> wrote:
> Seems it did work, however, the info window wasn't automaticly closed
> by removing the marker.

Marker and infowindow are different objects. If you have just one
infowindow instance, you can call myInfoWindow.close(). If you create
many InfoWindow instances you have to push them in an array. So you
can close them by a similar loop than you use for clearing markers.

I have also tried a brute method for clearing individual map panes.

function clearOverlays(){
var pane = document.getElementById("pane_1");
while(pane && pane.firstChild){
pane.removeChild(pane.firstChild);
}
}

It works but I would not recommend using it. Just experimenting.
Reply all
Reply to author
Forward
0 new messages