Oh man, I studied the code of all posted examples and tried it again
and again

I think it works much better now, but still don't work as it should. I
am done.
I need to to this as a project for my university but I don't come a
step further:

http://variouselmts.com/happytrees/map2.html

here is the code

        var map;
        var markers = new Array();

        function initialize() {

            if (GBrowserIsCompatible()) {

                function createmarker(point, label) {

                    var markerid = markers.length;
                    var marker = new GMarker(point, {title: markerid,
draggable: true});
                    markers[markerid] = marker;

                    GEvent.addListener(marker, "click", function() {

                        var latlngstr =
marker.getPoint().toUrlValue();;
                        var windowhtml = "";
                        windowhtml += "<h1>" + latlngstr + "</h1>";
                        windowhtml += marker.getTitle();
                        windowhtml += "<a
href='javascript:map.closeInfoWindow();
map.removeOverlay(clickmarker);'>remove</a>";

                        marker.openInfoWindowHtml(windowhtml);

                        });

                    GEvent.addListener(marker, 'dragstart', function()
{

                        map.closeInfoWindow();

                        });

                    GEvent.addListener(marker, 'dragend', function() {

                        var latlngstr =
marker.getPoint().toUrlValue();;
                        var windowhtml = "";
                        windowhtml += "<h1>" + latlngstr + "</h1>";
                        windowhtml += marker.getTitle();
                        windowhtml += "<a
href='javascript:map.closeInfoWindow();
map.removeOverlay(clickmarker);'>remove</a>";

                        marker.openInfoWindowHtml(windowhtml);

                        });

                    return marker;

                    };

                map = new GMap2(document.getElementById('map'));
                map.addControl(new GMapTypeControl());
                map.addControl(new GLargeMapControl());
                map.setCenter(new GLatLng(40.717079, -73.98571), 12);
                map.setMapType(G_SATELLITE_MAP);
                map.enableScrollWheelZoom();

                GEvent.addListener(map, 'click', function(overlay,
point) {

                    clickmarker = createmarker(point, 'click');
                    map.addOverlay(clickmarker);

                    var latlngstr =
clickmarker.getPoint().toUrlValue();;

                    var windowhtml = "";
                    windowhtml += "<h1>" + latlngstr + "</h1>";
                    windowhtml += clickmarker.getTitle();
                    windowhtml += "<a
href='javascript:map.closeInfoWindow();
map.removeOverlay(clickmarker);'>remove</a>";

                    clickmarker.openInfoWindowHtml(windowhtml);

                    });

                }

            else {

                alert('Sorry, the Google Maps API is not compatible
with this browser');

                }



            };

Can somebody help me with that? or explain it to me in a simple way,
thanks a lot

On Oct 3, 10:31 pm, Mike Williams <[EMAIL PROTECTED]> wrote:
> Code launched from a HTML <a href="javascript:..."> tag executes in
> global context, and can only access global variables.
>
> Your "map" and "markers" variables are local to your initialize()
> function, so they're not available in global context.
>
> When you get that working, you will need to do something to prevent
> someone clicking on "RemoveThis Marker" more than once. E.g. close the
> info window when youremovethe marker. Attempting toremoveanoverlay
> that has already been removed causes problems.
>
> --http://econym.org.uk/gmap
> The Blackpool Community Church Javascript Team

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