I have the below code,  it loads ok, but when i click on the map it
doesn't place a marker.
What should happen is that when you click on the map it should place a
marker and when clicked on the map a second time that it should place
a marker at the new location and remove the previous one so that there
is only ever one marker on the map??

<script type="text/javascript">

    //<![CDATA[
        function createMarker(point,name) {
        var marker = new GMarker(point,{title:name});
        return marker;
    }
    function mapclick(ov,pt) {
        if (marker) map.removeOverlay(marker);
        if (pt) {
                        marker = createMarker(pt,pt.toUrlValue());
            map.addOverlay(marker);
        }
        var match11 = /\(([-.\d]*), ([-.\d]*)/.exec(pt);
        if (match11) {
                        var lat = parseFloat( match11[1] );
                        var lon = parseFloat( match11[2] );
                        lat = lat.toFixed(6);
                        lon = lon.toFixed(6);
        }
        document.getElementById("lat").value = lat;
        if(document.getElementById("lat").value == "undefined") {
                        document.getElementById("lat").value = "";
        }
        document.getElementById("lon").value = lon;
        if(document.getElementById("lon").value == "undefined") {
                        document.getElementById("lon").value = "";
        }
    }
    function load() {
                if (GBrowserIsCompatible()) {
                        var map = new GMap2(document.getElementById("map"));
                        map.setCenter(new GLatLng(53.558584,-7.987061), 6);
                        map.addControl(new GLargeMapControl());
                        var marker = null;
                        
GEvent.addListener(map,"click",function(overlay,point){mapclick
(overlay,point)});
                }
    }

    //]]>
</script>
--~--~---------~--~----~------------~-------~--~----~
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