Marker content (infoWindow) Google Maps?

We've solved this, although we didn't think having the addListener outside of the for would make any difference, it seems to. Here's the answer.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

I'm trying to add infoWindow's to multiple markers on a Google Map. The closest I have come is to get an infoWindow to display the last address you can see in the array, on all markers. The bit of code I have pasted below does not work, I get an "Uncaught TypeError: Cannot read property '4' of undefined".

I'm sure this is a scope issue, but I'm going round in circles here and could do with some help: var hotels = 'ibis Birmingham Airport', 52.452656, -1.730548, 4, 'Ambassador RoadBickenhillSolihullBirminghamB26 3AW','(+44)1217805800','(+44)1217805810','info@ibisbhamairport. Com','http://www.booknowaddress. Com', 'ETAP Birmingham Airport', 52.452527, -1.731644, 3, 'Ambassador RoadBickenhillSolihullBirminghamB26 3QL','(+44)1217805858','(+44)1217805860','info@etapbhamairport.

Com','http://www.booknowaddress. Com', 'ibis Birmingham City Centre', 52.475162, -1.897208, 2, 'Ladywell WalkBirminghamB5 4ST','(+44)1216226010','(+44)1216226020','info@ibisbhamcity. Com','http://www.booknowaddress.

Com' ; for (var I = 0; I LatLng(hotelsi1, hotelsi2), map: map, icon: image, title: hotelsi0, zIndex: hotelsi2 }); var infoWindow = new google.maps.InfoWindow(); google.maps.event. AddListener(marker, 'click', function () { var markerContent = hotelsi4; infoWindow. SetContent(markerContent); infoWindow.

Open(map, this); }); } Thanks in anticipation. Javascript google-maps markers infowindow link|improve this question asked May 3 '11 at 11:40DarrylGodden208112 81% accept rate.

We've solved this, although we didn't think having the addListener outside of the for would make any difference, it seems to. Here's the answer: Create a new function with your information for the infoWindow in it: function addInfoWindow(marker, message) { var info = message; var infoWindow = new google.maps. InfoWindow({ content: message }); google.maps.event.

AddListener(marker, 'click', function () { infoWindow. Open(map, marker); }); } Then call the function with the array ID and the marker you want to create: addInfoWindow(marker, hotelsi3).

I looked through a lot of SO answers to variants of this question. Your answer was the clearest. Thank you.

– ZMorek Aug 30 '11 at 19:25.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions