use*_*660 12 google-maps-api-3
如果某个地点没有街景,我想找到最近的街景视图吗?
我能想到的唯一方法是.
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;
}
Run Code Online (Sandbox Code Playgroud)
但即使我想在10英里范围内找到街景,这也是非常昂贵的,我希望能在这些点之一找到街景,也就是说,我可能会错过街景的实际点.
有人可以指导我走向更好的方法吗?
小智 11
您可以尝试使用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... **/
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5278 次 |
| 最近记录: |