Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google maps api v3 - nearest streetview

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??

like image 528
user441660 Avatar asked Oct 22 '10 22:10

user441660


People also ask

Does Google Street View have a API?

Street View's API coverage is the same as that for the Google Maps application ( https://maps.google.com/ ). The list of currently supported cities for Street View is available at the Google Maps website.

Is Street View API free?

All use of Google Street View Publish API is free of charge.


1 Answers

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... **/
}
like image 127
Hakaesbe Avatar answered Oct 16 '22 16:10

Hakaesbe