对于已知坐标,我可以通过在mapOptions对象
中指定它来将各种控件设置为falsevar mapOptions = {
position: new google.maps.LatLng(37.869260, -122.254811),
zoom: 1,
pov: {
heading: 165,
pitch: 0
},
addressControl: false,
panControl: false,
linksControl: false,
zoomControl: false,
};
map = new google.maps.StreetViewPanorama(mapDiv, mapOptions);
但是,使用getPanoramaByLocation
latLng = new google.maps.LatLng(34,34);
radius = 500000
var sv = new google.maps.StreetViewService();
var map = new google.maps.StreetViewPanorama(mapDiv)
sv.getPanoramaByLocation(latLng, radius, function(data, status) {
if (status == google.maps.StreetViewStatus.OK) {
var nearStreetViewLocation = data.location.latLng;
map1.setPosition(nearStreetViewLocation);
map1.setZoom(1);
map1.setPov({
heading: 270,
pitch: 0
});
map1.setVisible(true);
}
});
我找不到像setPanControl或setZoomControl这样的方法。当我没有在单个对象中声明选项时,如何修改这些控件?
答案 0 :(得分:1)
对于没有特定setter方法的选项,请使用 set
的MVCObject
方法:
map1.set('panControl',true);
使用setValues
:
map1.setValues({ zoom:1,
pov:{
heading: 270,
pitch: 0
},
position:nearStreetViewLocation,
visible:true,
panControl:true,
zoomControl:true
});