I looked for error and I couldn\'t find it. Any google maps infoWindow always shows the same information for some reason.
Here is a coffeescript code
inf
you need to obtain closure on the variable company. You can do that by creating your markers in a separate function. for example:
infowindow = new google.maps.InfoWindow()
for(var n = 0 ; n < n companiesData.length ;n++){
createMarker(companiesData[n]);
}
function createMarker(data){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(parseFloat(data.latitude), parseFloat(data.longitude)),
map: map
})
#debugger ---> each company.name is different!
google.maps.event.addListener(marker, 'click', function(){
infowindow.setContent(data.name);
infowindow.open(map,this);
}
)
}
Explanation here.
I had the same... try to create marker in separate function. It helped for me.
Check it out: https://developers.google.com/maps/articles/phpsqlsearch_v3
Find code with "searchLocationsNear(center)" function.