Adding multiple markers with infowindows (Google Maps API)

后端 未结 6 1196
别跟我提以往
别跟我提以往 2020-11-29 17:28

I\'m currently using the following code the place multiple markers on a Google Map using their API.

The problem I\'m having is with multiple infowindows not working

6条回答
  •  天涯浪人
    2020-11-29 18:26

    var infowindow = null;
    infowindow = new google.maps.InfoWindow({
      content: "loading..."
    });
    for (i = 0; i < data.dbreturn.length; i++) { 
      var latilongi = data.dbreturn[i].mapa.split(',');
      var mapinha =  {lat: parseFloat(latilongi['0']), lng:     parseFloat(latilongi['1'])};
      var marker = new google.maps.Marker({
      position: mapinha,
      html: '
    '+data.dbreturn[i].nome+'
    ' }); google.maps.event.addListener(marker, "click", function () { infowindow.setContent(this.html); infowindow.open(map, this); }); }

提交回复
热议问题