Google maps open info window by default?

后端 未结 4 670
情话喂你
情话喂你 2020-12-13 01:44

The following example shows a simple Marker (standard icon) on Google maps for the location and when clicking the icon, it opens the info window. Can I show the info window

4条回答
  •  半阙折子戏
    2020-12-13 02:41

    You can run "open" directly on page load should open the window automatically, without a click.

    infowindow.open(map, marker);
    

    However, this might not autopan the map properly in some cases, leaving the top of the overlay off the edge of the map.

    A way that worked for me is to wrap it in a listener to the "tilesloaded" event on the map

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

提交回复
热议问题