I am so sorry to ask such a simple question, but I am really lost
right now. I read every post about that subject but it still doesn't
work.
I just add some marker on click and want to remove them via a link in
the info window.
Here is the code
<script type="text/javascript">
var markers = new Array();
var counter = 0;
google.load("maps", "2");
// Call this function when the page has been loaded
function initialize() {
var map = new
google.maps.Map2(document.getElementById("map"));
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
map.setCenter(new google.maps.LatLng(40.717079, -73.98571),
12);
map.setMapType(G_SATELLITE_MAP);
map.enableScrollWheelZoom();
GEvent.addListener(map, "click", function(overlay, latlng) {
counter++;
var marker = new GMarker(latlng, {title: counter,
draggable: true});
markers[counter] = marker;
var markerbox = "<div class=\"marker-box\">";
markerbox += "<h2>" + marker.getTitle() + "</h2>";
markerbox += "<span>Drag marker to the position where you
have plant a \"Happy Tree\" and <input type=\"submit\" value=\"save\">
it, forever!</span>";
markerbox += "<form action=\"backend/save.php\" method=
\"post\" accept-charset=\"utf-8\">";
markerbox += "<input type=\"hidden\" name=\"lat\" value=
\"GLatLng.lat() \">";
markerbox += "<input type=\"hidden\" name=\"lng\" value=
\"GLatLng.lng() \">";
markerbox += "";
markerbox += "<a href=
\"javascript:map.removeOverlay(markers[" + marker.getTitle() + "])
\">Remove This Marker</a>";
markerbox += "</form>";
markerbox += "</div>";
GEvent.addListener(marker, "dragstart", function() {
map.closeInfoWindow();
});
GEvent.addListener(marker, "dragend", function(point) {
marker.openInfoWindowHtml(markerbox);
});
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(markerbox);
});
map.addOverlay(marker);
marker.openInfoWindowHtml(markerbox);
});
};
google.setOnLoadCallback(initialize);
</script>
Here is the online example:
http://www.variouselmts.com/happytrees/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---