Google maps open info window by default?

后端 未结 4 671
情话喂你
情话喂你 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:23

    If you want to show the info window opened by default without click, just add a new code like bellow:

    Your code:

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

    So we have a new code like this:

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

    As you can see, we just add a little line code with infowindow.open(map,marker);

提交回复
热议问题