Hello everybody,
When I click a marker, I want to take in a form the information about a
marker, for instance the name of marker (which is loaded from an XML
database).
I know that I have to use event "listener", but it doesn't work:
function initialize() {
var mylatlng = new google.maps.LatLng(38.797896, -9.388701 );
var myOptions = {
zoom:15,
center: mylatlng,
mapTypeId: google.maps.MapTypeId.HYBRID
};
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var infoWindow = new google.maps.InfoWindow;
downloadUrl("xmloutdom1.php", function(data) {
var markers = data.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var name = markers[i].getAttribute("name");
var type = markers[i].getAttribute("type");
var description = markers[i].getAttribute("description");
var picture= markers[i].getAttribute("picture");
var address = markers[i].getAttribute("address");
var link = markers[i].getAttribute("link");
var point = new
google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
var html = '<div id="info"'+
'<h2> '+name+' </h2> '+
'<img src="images/'+ picture +'" alt=""/>'+
'<p>'+ description +' </p>'+
'<p> <a href="'+ link +'">'+ 'Link: '+name +' </a></p>'+
'<p>'+'Address:'+ address +'</p>' +
'</div>';
var icon = customIcons[type] || {};
var marker = new google.maps.Marker({
map: map,
position: point,
title:name,
icon: icon.icon
//,icon:customIcons[type]
//icon: "
http://google-maps-icons.googlecode.com/files/coffee.png"
});
bindInfoWindow(marker, map, infoWindow, html);
google.maps.event.addListener(marker,name, 'click', function(event) {
var form=document.getElementById("delete_form");
//var latf=form.elements[0];
//latf.value=event.latLng.lat();
var nume=form.elements[1];
//lngf.value=event.latLng.lng();
nume.value=name;
});
}
});
}
First I tried to take latitude and longitude, but nigther like this it
doesn't work.
Any ideas?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.