是否有一种方法来请求主干道Google StreetView全景数据,而不是对给定位置(纬度/经度)的后巷全景数据?
我正在使用Google API从我们的用户提供的家庭地址中检索街景全景图。它对我尝试过的大多数地址都很有效,但我注意到加州的许多房产也有后巷的街景,API接缝会不断地返回后巷全景图,而不是主干道(房产前)全景图。
我不想向用户展示他们家的后巷全景,而是主干道全景图。如果我在maps.google.com上查找相同的地址,我就会看到房子的前面,但是当我通过API请求相同的地址时,我就得到了后面的小巷。
当前使用的进程是:
测试地址:
如有任何意见或建议,将不胜感激。谢谢!
发布于 2015-07-02 13:33:04
使用“指示”服务从所需地址获取指向其自身的指示。使用该位置,而不是街头视图位置的地理编码器结果。使用地理编码器的结果(希望屋顶精确的结果)的地方看。
相关问题:使用Google StreetView面向目标建筑示例:
代码片段:
var sv = new google.maps.StreetViewService();
var geocoder = new google.maps.Geocoder();
var directionsService = new google.maps.DirectionsService();
var panorama;
var address = "333 S Rodeo Dr, Beverly Hills, CA, USA, 90212";
var myLatLng;
function initialize() {
panorama = new google.maps.StreetViewPanorama(document.getElementById("pano"));
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
myLatLng = results[0].geometry.location;
// find a Streetview location on the road
var request = {
origin: address,
destination: address,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, directionsCallback);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
function processSVData(data, status) {
if (status == google.maps.StreetViewStatus.OK) {
panorama.setPano(data.location.pano);
var heading = google.maps.geometry.spherical.computeHeading(data.location.latLng, myLatLng);
panorama.setPov({
heading: heading,
pitch: 0,
zoom: 1
});
panorama.setVisible(true);
} else {
alert("Street View data not found for this location.");
}
}
function directionsCallback(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var latlng = response.routes[0].legs[0].start_location;
sv.getPanoramaByLocation(latlng, 50, processSVData);
} else {
alert("Directions service not successfull for the following reason:" + status);
}
}<script src="https://maps.googleapis.com/maps/api/js?libraries=geometry&key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="pano" style="width: 425px; height: 400px;float:left"></div>
https://stackoverflow.com/questions/31176327
复制相似问题