thank you Larry! removeOverlays() didn't work, but I checked the API to find out that it's clearOverlays(). just putting that here in case a future reader is in a similar bind.
much appreciated! On Jun 5, 2:16 pm, "[email protected]" <[email protected]> wrote: > On Jun 5, 1:57 pm, 411NET <[email protected]> wrote: > > > Hello, > > > I'm using the following code to get the lat/lon of a user-clicked > > point on the map. The problem is that the map keeps adding points. I > > only want it to show the latest point. I'm not quite sure how to do > > that. Any suggestions? > > remove the previous marker before adding the next... > either do: > map.removeOverlays() [removes all the overlays] > or > make marker global and do: > map.removeOverlay(marker); > > If you can't get those to work, post a link to your map, not code. > > -- Larry > > > > > <script type="text/javascript"> > > var map = new GMap(document.getElementById("map")); > > map.centerAndZoom(new GPoint(-92.27722, 34.74875), 4); > > > GEvent.addListener(map, 'click', function(overlay, point) { > > lastpoint = document.getElementById('lastpoint').value; > > > if (overlay) { > > map.removeOverlay(overlay); > > } else if (point) { > > map.recenterOrPanToLatLng(point); > > var marker = new GMarker(point); > > map.addOverlay(marker); > > } > > }); > > > // Recenter Map and add Coords by clicking the map > > GEvent.addListener(map, 'click', function(overlay, point) { > > document.getElementById("submit_lat").value=point.y; > > document.getElementById("submit_lon").value=point.x; > > }); > > </script> > > > Much appreciated, thank you! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
