GMaps V3 InfoWindow - disable the close “x” button

前端 未结 22 1026
青春惊慌失措
青春惊慌失措 2020-12-05 09:14

From what I see, in v2 of GMaps API there was a property \"buttons\" of the InfoWindow object that one could define in a way that given InfoWindow has no close button:

22条回答
  •  一生所求
    2020-12-05 10:09

    I couldn't get any of the $(".gm-style-iw").next("div").hide(); answers to work even when calling the code after the DOM was loaded, since there was a delay between the code being called and the info window being created. What I did was create an interval that runs until it finds the info window and removes the "X" element. If there's a better way please tell me.

    var removeCloseButton = setInterval(
        function()
        {
            if ($(".gm-style-iw").length)
            {
                $(".gm-style-iw").next("div").remove();
                clearInterval(removeCloseButton);
            }
        },
        10
    );
    

提交回复
热议问题