因此,我使用禁用了嵌入到我的网站中的google map的用户界面,disableDefaultUI: true
但现在我想在map上添加倾斜选项,使我们能够看到map的不同视图。
编辑:问题已经回答。 rotateControl: true
如果要显示“倾斜”控件,则只能将其与旋转控件一起显示。要启用它,请添加rotateControl: true
到您的mapOptions中:
rotateControl: true
从文档中:
新增功能(默认为v3.22):
外观:旋转控件显示为两个执行不同功能的可见控件。第一个是倾斜按钮,允许用户将图像倾斜到45°角。第二个是旋转按钮,允许用户倾斜时更改图像的方位。默认位置:RIGHT_BOTTOM。
注意(如@Matthew在评论中指出的那样),您只会在具有45度影像的区域(市中心等)中看到旋转控件
代码段:
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {
lat: 45.518,
lng: -122.672
},
zoom: 18,
disableDefaultUI: true,
mapTypeId: google.maps.MapTypeId.SATELLITE,
tilt: 45,
rotateControl: true
});
}
google.maps.event.addDomListener(window, 'load', initMap);
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map"></div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句