简体   繁体   English

在整个Google地图上放置透明的覆盖层(如模式封面)

[英]Place transparent overlay over entire google map (like a modal cover)

Hello as the title suggests 你好,如标题所示

I have a map that for the most part fills the screen besides a navigation bar that hangs on the size absolute positioned. 我有一张地图,除了一个导航栏外,大部分都填满了屏幕。

When a marker is clicked I have an info box popping up with location information. 单击标记后,我会弹出一个带有位置信息的信息框。 I would like to put a black transparent layer behind this, over top of the map, to prevent map clicks until the close the information box. 我想在地图上方的此后面放置一个黑色透明层,以防止在关闭信息框之前点击地图。

I have tried to use custom overlays, mainly using another infobox to layer but in order to position the info box it is offsetting the top and left positions to meet the marker its supposed to cover. 我尝试使用自定义叠加层,主要是使用另一个信息框进行分层,但是为了放置信息框,它要偏移顶部和左侧的位置,以满足其应覆盖的标记。

So what I am stuck with right now is a black transparent box, 5000px by 5000px that appears to the bottom left of the pin. 因此,我现在所停留的是一个黑色的透明框,它在图钉的左下角显示了5000px x 5000px。

Is there a way to set the overlay to match the google map canvas? 有没有一种方法可以设置覆盖层以匹配Google地图画布? top, left, right, bottom sides. 顶部,左侧,右侧,底部。

Maybe this could be a solution instead of using an overlay. 也许这可能是一种解决方案,而不是使用覆盖。 You could turn off the controls so the user can't interact with the map. 您可以关闭控件,以便用户无法与地图进行交互。

If you use: 如果您使用:

map.setOptions({draggable: false, 
        zoomControl: false, 
        scrollwheel: false, 
        disableDoubleClickZoom: true,
        streetViewControl: false,
        panControl: false,
        mapTypeControl:false});

You turn off the controls on your map. 您关闭地图上的控件。 Where map is your map object. map是您的地图对象。 And whenever you close your infowindow you reverse this process to enable everything. 而且,每当关闭信息窗口时,您都将撤消此过程以启用所有功能。

我最终使用jquery将顶部,左侧位置设置为0,并将叠加层移动到地图窗格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM