Question

Lorsque streetview n'est pas disponible pour un certain endroit, je voudrais trouver le plus proche possible avec emplacement streetview?

La seule façon que je pouvais penser est.

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;

}

Mais c'est ridiculement cher, même si je veux trouver streetview dans un rayon de 10 mile et je compte sur la chance de trouver streetview à l'un de ces points, à savoir, je pouvais manquer un point réel avec Streetview.

Quelqu'un peut-il s'il vous plaît me diriger vers une meilleure approche ??

Était-ce utile?

La solution

Vous pouvez essayer d'utiliser le StreetViewService pour vous aider à trouver une vue sur la rue existante la plus proche:

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... **/
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top