Google Maps infoWindow without marker?

后端 未结 3 1434
名媛妹妹
名媛妹妹 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条回答
  •  猫巷女王i
    2021-01-06 00:23

    If the position is set, there is no problem showing the info window

    function initMap() {
      var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 6,
      center: {lat: 55.6761, lng: 12.5683},
      mapTypeId: google.maps.MapTypeId.TERRAIN
    });
    var infowindow = new google.maps.InfoWindow({
      content: "Copenhagen"
    });
    infowindow.setPosition({lat: 55.6761, lng: 12.5683});
    infowindow.open(map);
    }
    

提交回复
热议问题