Google Maps infoWindow without marker?

后端 未结 3 1403
名媛妹妹
名媛妹妹 2021-01-05 23:46

According to the documention a marker is optional with an infoWindow, so how is this achieved please? I have tried infowindow.open(map) and infowindow.open(map,

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-06 00:10

    Since the api has changed, it is not possible to set position on info window any more. the solution i found is to add a marker to the map with visibility false:

    this.map.addMarker({
            position: {
              'lat': sites[0].latitude,
              'lng': sites[0].longitude
            },
            // setting visible false since the icon will be the poi icon
            visible: false
          }).then((marker: Marker) => {
    
            this.htmInfoWindow.open(marker);
          });
    

提交回复
热议问题