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?

<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
-~----------~----~----~----~------~----~------~--~---

Reply via email to