Have just one InfoWindow open in Google Maps API v3

后端 未结 10 926
盖世英雄少女心
盖世英雄少女心 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:35

    You need to keep track of your previous InfoWindow object and call the close method on it when you handle the click event on a new marker.

    N.B It is not necessary to call close on the shared info window object, calling open with a different marker will automatically close the original. See Daniel's answer for details.

提交回复
热议问题