Have just one InfoWindow open in Google Maps API v3

后端 未结 10 900
盖世英雄少女心
盖世英雄少女心 2020-11-28 03:18

I need to have only one InfoWindow open on my Google Map. I need to close all other InfoWindows before I open a new one.

Can someone show me how to do this?

10条回答
  •  执念已碎
    2020-11-28 03:47

    Solved it this way:

    function window(content){
        google.maps.event.addListener(marker,'click', (function(){
            infowindow.close();
            infowindow = new google.maps.InfoWindow({
                content: content
            });
            infowindow.open(map, this);
        }))
    }
    window(contentHtml);
    

提交回复
热议问题