谷歌地图api v3 - 最近的街景 [英] google maps api v3 - nearest streetview
问题描述
当街景不适用于某个特定位置时,我希望找到最近的街景位置?
我能想到的唯一方法就是。
radius = 0;
noOfPoints = 3;
(半径<10英里){
半径=半径+ 0.2英里
点=计算4 *在此半径处的noOfPoints
循环(点)
{
if(streetview visibile for point)
宾果,休息;
}
如果宾果游戏中断,
noOfPOints = noOfPoints + 1;
$ / code>
但即使我想要找到streetview,在10英里半径范围内,我希望能够在这些地点之一找到街景,也就是说,我可能会错过街景的实际点。
有人可以请指导我采取更好的方法??您可以尝试使用StreetViewService帮助您找到最近的现有街景:
var astorPlace = new google.maps.LatLng(40.729884,-73.990988);
var webService = new google.maps.StreetViewService();
/ **检查周长为50米** /
var checkaround = 50;
/ ** checkNearestStreetView是一个有效的回调函数** /
webService.getPanoramaByLocation(astorPlace,checkaround,checkNearestStreetView);
函数checkNearestStreetView(panoData){
if(panoData){
if(panoData.location){
if(panoData。 location.latLng){
/ **做得好,您可以使用最近的现有街景坐标** /
}
}
}
/ **其他某事...... ** /
}
When streetview is not available for a certain location, I would like to find the nearest possible location with streetview?
The only way I could think of is.
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;
}
But this is ridiculously expensive even if I want to find streetview within a 10-mile radius and I am counting on luck to find streetview at one of these points, i.e, I could just miss an actual point with streetview.
can somebody please direct me towards a better approach??
You can try to use the StreetViewService to help you find a nearest existing street view:
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... **/
}
这篇关于谷歌地图api v3 - 最近的街景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!