我可以启用/禁用关闭按钮,如下所示:enableCloseButton: true
AFAIK没有选项可以将此控件定位在默认右上角的任何位置。
文档没有提供有关此特定问题的详细信息: http://code.google.com/apis/maps/documentation/javascript/services.html#StreetViewControls
我是创建自定义控件的唯一选择吗?看起来很奇怪。
答案 0 :(得分:0)
您可以创建自己的按钮并点击通话
map.getStreetView().setVisible(false);
答案 1 :(得分:0)
您可以尝试以下
CSS
.btn {
margin-top: 2rem;
background: #3498db;
background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
background-image: -moz-linear-gradient(top, #3498db, #2980b9);
background-image: -ms-linear-gradient(top, #3498db, #2980b9);
background-image: -o-linear-gradient(top, #3498db, #2980b9);
background-image: linear-gradient(to bottom, #3498db, #2980b9);
-webkit-border-radius: 28;
-moz-border-radius: 28;
border-radius: 28px;
font-family: Arial;
color: #ffffff;
font-size: 20px;
padding: 10px 20px 10px 20px;
text-decoration: none;
}
.btn:hover {
background: #3cb0fd;
background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
text-decoration: none;
}
HTML
<button id="closeStreetView" class="btn">Click me</button>
的Javascript
var closeButton = document.querySelector('#closeStreetView'),
controlPosition = google.maps.ControlPosition[config.streetViewCloseButtonLocation];
var streetView = map.getStreetView();
streetView.setOptions({ enableCloseButton: false });
streetView.controls[ controlPosition ].push( closeButton );
google.maps.event.addDomListener(closeButton, 'click', function(){
streetView.setVisible(false);