javascript StreetView API:隐藏全屏控件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32654034/
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
StreetView API: Hiding FullScreen Control
提问by matthiasdv
I am trying to hide the toggle fullscreen element in the Streetview API HUD.
我试图在 Streetview API HUD 中隐藏切换全屏元素。
panorama = new google.maps.StreetViewPanorama(document.getElementById(data.id), {
position : new google.maps.LatLng(data.lat, data.lng),
pov: {
heading : Number(data.heading),
pitch : Number(data.pitch)
},
linksControl: false,
panControl: false,
addressControl: false,
enableCloseButton: false,
zoomControl: false,
fullScreenControl: false,
enableCloseButton: false,
addressControlOptions: {
position: google.maps.ControlPosition.BOTTOM_CENTER
}
});
These options are specced here. All the options are working except for the fullScreenControl
这些选项在此处指定。除了fullScreenControl
My code can be viewed live here. The UI element is in the top right corner of the viewport.
The documentation warns as follows:
文档警告如下:
Note: This page describes the controls available in version 3.22 and later of the Google Maps JavaScript API. If you want to continue using the earlier set of controls for a while, you can set google.maps.controlStyle = 'azteca' in v3.22. Read more about the changes to the controls in this article: What's New in the v3.22 Map Controls.
注意:本页介绍了 Google Maps JavaScript API 3.22 及更高版本中可用的控件。如果您想继续使用之前的一组控件一段时间,您可以在 v3.22 中设置 google.maps.controlStyle = 'azteca'。在本文中阅读有关控件更改的更多信息:v3.22 地图控件中的新增功能。
However I am linking to the API Js file as follows:
但是我链接到 API Js 文件如下:
<script src="//maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
And 3.exp should be 3.22 at the moment of writing.
并且 3.exp 在编写时应该是 3.22。
What am I missing here?
我在这里错过了什么?
采纳答案by user3586022
Another solution is to use css to hide the fullscreen element:
另一种解决方案是使用 css 来隐藏全屏元素:
.gm-style > div:nth-child(10){
display:none;
}
回答by papy98
fullscreenControl: false
instead of fullScreenControl: false
fullscreenControl: false
代替 fullScreenControl: false
回答by XAos SPB
The following is incorrect. It doesn't error but it has no effect on the control.
以下说法不正确。它不会出错,但对控件没有影响。
fullScreenControl: false, -- this is not right
Correct code is
正确的代码是
fullscreenControl: false,
See: https://developers.google.com/maps/documentation/javascript/reference
请参阅:https: //developers.google.com/maps/documentation/javascript/reference
回答by Romulo
I believe there is a minor flaw in the API at this moment. I′ve made some tests and was also unable to remove the full screen control with the fullScreenControlOptions field, as specified in the documentation.
我相信此时 API 中存在一个小缺陷。我进行了一些测试,但也无法使用 fullScreenControlOptions 字段删除全屏控件,如文档中所述。
The full screen control is displayed even if you set the disableDefaultUI to true.
即使您将 disableDefaultUI 设置为 true,也会显示全屏控件。
I know this may not be the better way to get rid of the element, but you can do something like:
我知道这可能不是摆脱元素的更好方法,但您可以执行以下操作:
var FULL_SCREEN_CONTROL_STYLE = {
width: '25px',
height: '25px',
top: '0px',
right: '0px',
position: 'absolute',
overflow: 'hidden'
};
var children = panorama.getContainer().getElementsByTagName('div');
for (var i = 0; i<children.length; i++) {
var current = children[i];
var match = true;
for (var k in FULL_SCREEN_CONTROL_STYLE) {
if (current.style[k] != FULL_SCREEN_CONTROL_STYLE[k]) {
match = false;
}
}
if (match) { // THIS IS OUR ELEMENT
current.parentElement.removeChild(current);
}
}
回答by Nic Howard
Michal Szyndel has it correct. The s in screen is lower case. I suggest his answer is changed to the correct answer. I Tested today fullscreenControl works but fullScreenControl does not.
Michal Szyndel 说得对。屏幕中的 s 是小写的。我建议他的答案改为正确答案。我今天测试 fullscreenControl 有效,但 fullScreenControl 无效。
回答by JavaScripter
With the newest release of Googlemap v3.22, v3.23 on 18 January 2016, following will do the job:
随着 2016 年 1 月 18 日最新版本的 Googlemap v3.22、v3.23,以下将完成这项工作:
.gm-fullscreen-control {
display: none;
}