How do I display an information box when clicking on the marker? I tried to do following the documentation, but when I click, the box appears but not the information inside it.
//Center
var mapProp = {
center: new google.maps.LatLng(-14.235004, -51.92528),
zoom: 5,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
//Map
var map = new google.maps.Map(document.getElementById("googleMapsOne"), mapProp);
var contentString = '<div id="content">Informação</div>';
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 200
});
// Circle
var mycityCircle = new google.maps.Circle({
center: new google.maps.LatLng(7.2964, 80.6350),
radius: l,
strokeOpacity: 0.8,
strokeWeight: 2,
fillOpacity: 0.2
});
mycityCircle.setMap(map);
// Marker
locations.map(function(val){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(val[1], val[2]),
icon: 'images/pin.png',
map: map,
animation: google.maps.Animation.BOUNCE
});
//marker.setMap(map)
marker.addListener('click', function() {
infowindow.open(map, marker);
});
});
I need to add to each Marker, a different text (that comes from my API), I tried to put it inside the Map, but that does not work