I'm finding that StreetViewService is reporting a status "OK" for a latLng pair for which it has no image. Example code:
let sv = new google.maps.StreetViewService();
let tokyo = {lat: 35.6895,lng: 139.6917};
sv.getPanorama({location: tokyo, radius: 250}, svCheck);
function svCheck(data, status) {
if (status === 'OK') {
console.log("OK for "+data.location.latLng+" at ID "+data.location.pano);
}
else {
console.log("STATUS NOT OK");
}
}
This code will return a status of "OK" but a subsequent request to pull that image gives me one of the "Sorry, we have no imagery for here" messages. For example, with this URL---based on the pano ID the above---the code incorrectly returns a status of OK (you'll have to add by your own API key to follow this link):
My understanding is that StreetViewService's getPanorama() should only return status OK if subsequent requests to the static API will actually return an image. What's going on here?
It sounds like a bug in the Street View Image API. If I check the pano id
CAoSLEFGMVFpcFB3ZWxWT21OX196WVc2ajlGeE9qbGptTHFHc2RNRjBwRlYyamhwfrom your example using the Street View Image Metadata API:https://maps.googleapis.com/maps/api/streetview/metadata?pano=CAoSLEFGMVFpcFB3ZWxWT21OX196WVc2ajlGeE9qbGptTHFHc2RNRjBwRlYyamhw&key=MY_API_KEYI get the following response
That means that pano id is valid, it exists in Google database, but it is not available via Street View Image API.
We can see that this pano was uploaded by external user, so it is not typical Google street view image. I know that Google experienced issues with business generated panos in the past. For reference you can have a look at the following bugs in the Google issue tracker:
https://issuetracker.google.com/issues/35829459
https://issuetracker.google.com/issues/77676413
Both are marked as fixed, however it looks like in your case it is not true. At this point I would suggest report an issue to Google via their issue tracker again.
As a workaround consider requesting only Google's outdoor imagery. You can specify
sourceproperty in your Street View pano request as shown in my exampleWith modified request you will get a pano ID
rHMU4M8-OvVuL5ALS0OlNg. If you check it with metadata APIhttps://maps.googleapis.com/maps/api/streetview/metadata?pano=rHMU4M8-OvVuL5ALS0OlNg&key=YOUR_API_KEYyou will get the following response
This pano belongs to Google and it works correctly with Street View Image API
https://maps.googleapis.com/maps/api/streetview?pano=rHMU4M8-OvVuL5ALS0OlNg&size=600x400&key=YOUR_API_KEY