如果某个地点没有街景,我想找到最近的街景视图?
我能想到的唯一方法是。
radius = 0;
noOfPoints = 3;
while(radius < 10 miles){
radius = radius + 0.2 miles
points = calculate 4 * noOfPoints at this radius
loop(points)
{
if(streetview visibile for point)
bingo, break;
}
break if bingo;
noOfPOints = noOfPoints+1;
}
但即使我想找到10英里半径范围内的街景,这也是非常昂贵的,我依靠运气在其中一个点找到街景,也就是说,我可能会错过街景的实际点。
有人可以指示我采取更好的方法吗?
答案 0 :(得分:10)
您可以尝试使用StreetViewService来帮助您找到最近的现有街道视图:
var astorPlace = new google.maps.LatLng(40.729884, -73.990988);
var webService = new google.maps.StreetViewService();
/**Check in a perimeter of 50 meters**/
var checkaround = 50;
/** checkNearestStreetView is a valid callback function **/
webService.getPanoramaByLocation(astorPlace,checkaround ,checkNearestStreetView);
function checkNearestStreetView(panoData){
if(panoData){
if(panoData.location){
if(panoData.location.latLng){
/**Well done you can use a nearest existing street view coordinates**/
}
}
}
/** Else do something... **/
}