我知道半径小于 50 米的 getPanoramaByLocation 将返回最近的街景全景。然而,对于某些地点,并不总是有街景。所以我正在做的是这样的:
function insider_function(locations) {
var place = new google.maps.LatLng(locations[local_idx].lat,locations[local_idx].lng);
sv.getPanoramaByLocation(place, 50, function(data, status) {
if (status == google.maps.StreetViewStatus.OK) {
insider_function_2(locations[local_idx], data);
} else {
sv.getPanoramaByLocation(place, 100, function(data, status) {
if (status == google.maps.StreetViewStatus.OK) {
insider_function_2(locations[local_idx], data);
} else {
alert('Internal error: ' + status + locations[local_idx]);
}
}
}
如果半径 50 没有返回任何结果,我会调用半径 100。但我仍然收到某些地址的 ZERO_RESULT 警报。如果我传递一个非常大的数字,比如 9999,我可能会在大多数其他具有封闭街景的位置获得非常远的街景。
那么获得半径大于 50 的最近街景全景的最佳方法是什么。
我不确定谷歌地图是如何做到这一点的。
例如,如果我使用“2300 Geng Rd, Palo Alto, CA”,则坐标为 37.4513333,-122.1214268。半径为 100 的 getPanoramaByLocation 将返回零结果,但有街景:https://www.google.com/maps/place/2300+Geng+Rd,+Palo+Alto,+CA+94303/@37.4513333,-122.1214268 https://www.google.com/maps/place/2300+Geng+Rd,+Palo+Alto,+CA+94303/@37.4513333,-122.1214268