I'm working with the Google Map API and after adding the infowindow in the bookmarks, I noticed that they are repeating themselves, but I could not resolve them.
Can anyone take a look at the code below and tell me what's going on? I'm loading into a Bootstrap modal.
Code:
$().click(function(e) {
...
// data <- é um json com algo mais ou menos assim:
// {[lat: 21.030300,long: 23.003002,tag: 'XXTO'],[lat: 20.22100,long: 21.113002,tag: 'NNTO']}
var map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var infowindow = new google.maps.InfoWindow();
var marker, i,pos;
for (var item in data)
{
pos = new google.maps.LatLng(data[item].Lat,data[item].Long);
marker = new google.maps.Marker({
position: pos,
map: map,
icon: '/prj/assets/imgs/lamp.png'
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent('Tag n°:' + data[item].tag);
infowindow.open(map, marker);
}
})(marker, i));
}
$("#modalMaps").on("shown.bs.modal", function(e) {
google.maps.event.trigger(map, "resize");
return map.setCenter(pos);
});
$("#modalMaps").modal();
}