'm quite new at Javascript and Google Maps but I could run the google
map that I was programming since I tried to show on the map more than
one marker, each one with different information (title, image, url
link) in the infowindow. I've searched on the net for the solution,
also in your related questions, and tried several solutions, but I'm
not able to find it. I post the code here (which is in the file
map.js), I guess that it must be a very silly mistake, but I can't see
it. I will really thank you if you could advise me.
enter code here (function() {
// Defining variables that need to be available to some functions
var map, infoWindow;
window.onload = function() {
// Creating a map
var options = {
zoom: 14,
center: new google.maps.LatLng(41.186, 1.0176),
mapTypeId: google.maps.MapTypeId.HYBRID,
streetViewControl: true,
scaleControl: true,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
position: google.maps.ControlPosition.TOP_RIGHT,
mapTypeIds: [
google.maps.MapTypeId.HYBRID,
google.maps.MapTypeId.SATELLITE,
google.maps.MapTypeId.TERRAIN
]
}};
map = new google.maps.Map(document.getElementById('map'),
options);
//Afegir kml:
http://code.google.com/apis/maps/documentation/javascript/overlays.html#KMLLayers
var ctaLayer = new google.maps.KmlLayer('http://dl.dropbox.com/u/
2697623/ReplaRocabrunaRepla_modif.kml');
ctaLayer.setMap(map);
var punts = [
{latitude: 41.17, longitude: 1.02, title: "Les Borges del Camp",
infoWindowContent: "<strong>Les Borges del Camp</strong><br/><div
id="info"><img src="img/borges.jpg" alt="" /><br/><a href=\"http://
www.lesborgesdelcamp.com\">Ajuntament de les Borges del Camp</a>"},
{latitude: 41.18, longitude: 1.0185, title: "Un altre punt",
infoWindowContent: "<strong>Un altre punt</strong><br/><div
id="info"><img src="img/borges.jpg" alt="" /><br /><a href=\"http://
www.google.com\">Ajuntament de les Borges del Camp</a>"},
];
var infowindow = new google.maps.InfoWindow();
var marker, i;
for (i = 0; i < punts.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(punts[i][1], punts[i][2]),
map: map
});
google.maps.event.addListener(marker, 'click', (function(marker,
i) {
return function() {
infowindow.setContent(punts[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}
--
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.