vendredi 2 août 2019

how to fix info window in google map

I'm trying to display infowindow in google map, but it showing last marker info not all marker

    let myLatlng = new window.google.maps.LatLng(-33.890542, 151.274856 );
    let mapOptions = {
      zoom: 13,
      center: myLatlng,
      scrollwheel: true,  

      }; 
    var locations = [
      ['Bondi Beach', -33.890542, 151.274856, 4],
      ['Coogee Beach', -33.923036, 151.259052, 5],
      ['Cronulla Beach', -34.028249, 151.157507, 3],
      ['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
      ['Maroubra BeachManly Beach Manly Beach Manly Beach', -33.950198, 151.259302, 1]
    ];

    let map = new window.google.maps.Map(
      document.getElementById("map"),
      mapOptions
      );



    var count;
    var marker=[];
    for (count = 0; count < locations.length; count++) {  
      marker = new google.maps.Marker({
      position: new google.maps.LatLng(locations[count][1], locations[count][2]),
      map: map,
      title: locations[count][0]
      });
       }


    var infowindow = new google.maps.InfoWindow({
      content:"<div></div>"
      });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
      });

    marker.setMap(map);




Aucun commentaire:

Enregistrer un commentaire