7
How do I display an information box when I click on Mark? I tried 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 also inside the Map, but there it does not work
Read more about formatting: How we should format questions and answers?
– UzumakiArtanis