I know there are at least a couple of questions like this
detecting "we have no imagery" of google maps street view static images
These articles offer a couple of solutions. The two most popular I've seen here and via Google searaches are:
- Detecting the size of the image to determine if you got a "good" image or not from the google static image API
- Call the getPanoramaByLocation service to determine if streetview is available for a location
Unfortunately, I don't want to use the first solution because it feels like the hack, and the second solution does not always seem to work.
var center = new google.maps.LatLng(latitude, longitude);
var streetViewService = new google.maps.StreetViewService();
var maxDistanceFromCenter = 75; //meters
streetViewService.getPanoramaByLocation(center, maxDistanceFromCenter, function (streetViewPanoramaData, status) {
if (status === google.maps.StreetViewStatus.OK) {
var key = /**smarty** #mapKey# **smarty**/;
var url = 'http://maps.googleapis.com/maps/api/streetview?size=320x320&location=' + latitude + ',%20' + longitude + '&sensor=false&key=' + key;
jQuery('.ui-page-active .streetView').attr('src', url);
} else {
console.log('error calling street view');
}
});
};
This code will correctly determine if panoramic imagery is available for a location, BUT sometimes static imagery is not available for that exact same location.
I started at 100 for my getPanoramaByLocation radius and that seemed like a safe number, but then I found a case where I was getting the "Sorry, we have no imagery here" error. So I went to 75, now I have to go to 50.
It seems like getPanoramaByLocation is not a safe indicator of static streetview imagery being available, or maybe it is but there's a particular value for the radius that should be used. I can't find it in the docs though. So my question: what's the safest radius to use for my maxDistanceFromCenter?