javascript 从谷歌地图信息窗口中删除关闭图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20544932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
remove close icon from the google map info window
提问by Visva
How to remove close icon of info window in google map. I tried to remove this icon, but couldn't find id or class for that.
如何删除谷歌地图中信息窗口的关闭图标。我试图删除这个图标,但找不到它的 id 或 class。
So can anyone help me to remove close icon from info window?
那么谁能帮我从信息窗口中删除关闭图标?
回答by Eugene Godun
You can hide close button with CSS:
您可以使用 CSS 隐藏关闭按钮:
.gm-style-iw + div {display: none;}
回答by HaxxanRaxa
This worked for me with just css
这只用 css 就对我有用
.gm-ui-hover-effect {
display: none !important;
}
回答by Jovanni G
I tried all suggestions above, but failed. I tried using jquery $('.gm-style-iw').next().hide()
, it did not work as well.
我尝试了上面的所有建议,但失败了。我尝试使用 jquery $('.gm-style-iw').next().hide()
,但效果不佳。
This is what worked for me, in case someone needs it. This is what I did with GMAP API V3.
这对我有用,以防万一有人需要它。这就是我使用 GMAP API V3 所做的。
.gm-style .gm-style-iw + div {
display: none; /* <-- this will generally work on the fly. */
visibility: hidden; /* this 2 lines below are just for hard hiding. :) */
opacity: 0;
}
Generally, what it does is, it looks for direct sibling of that gm-style-iw
which is created dynamically by the API. The div
right next to the gm-style-iw
is the close button.
通常,它的作用是寻找gm-style-iw
由 API 动态创建的直接兄弟。div
旁边的右侧gm-style-iw
是关闭按钮。
Hope that helps. :)
希望有帮助。:)
回答by PeeBee
button.gm-ui-hover-effect {
visibility: hidden;
}
That works as at today in Chrome and Edge
这在今天的 Chrome 和 Edge 中有效
回答by Hady Zeitouny
You can try this
你可以试试这个
::ng-deep .gm-style .gm-style-iw-c button {
display: none !important;
}
The magic inside it is ::ng-deep modifier that can search deeply for the styles and override them.
它里面的魔法是 ::ng-deep 修饰符,它可以深入搜索样式并覆盖它们。
回答by Amit kumar
You can try this
你可以试试这个
.gm-style-iw + div{ display: none; } // hide div
.gm-style-iw + div + img{ display: none; } // hide img
回答by Shahe
For people using Google Maps API v2, this function will open an info window with no close icon:
对于使用 Google Maps API v2 的人,此功能将打开一个没有关闭图标的信息窗口:
openInfoWindowHtml(html, {
maxWidth: 200, buttons: { close: { visible: false } }
});
回答by Agu Dondo
I did it setting closeBoxURL
to an empty string on the options object
我closeBoxURL
在选项对象上设置为空字符串
infoboxOptions = {
closeBoxURL: '',
...
}
var infobox = new InfoBox(infoboxOptions);