0

I'm using Google streetview Image API in order to get the street view of a particular address. When the address is not found, I would like to show my own placeholder image instead of the image returned by Google. Does someone know how to do that? As I feel, the only way I can distinguish between a valid image and invalid image is, checking the image size (If the image size is less than like 4KB, it's most probably the Google default image for street view not found). I'm not really proud of myself for that invention so that's why I'm searching on a more reliable and nice way.

I'm happy to use any other API as well as long as it does the job.

Thanks.

Ruchira
  • 943
  • 11
  • 16

2 Answers2

3

Do a check on the StreetViewService to see if there is coverage, then do whatever street view image API calls you need to do within there.

var sv = new google.maps.StreetViewService();

sv.getPanoramaByLocation(myLatlng, 50, function(data, status) {
    if (status == 'OK') {
        console.log('SV');
    }
    else {
        console.log('no SV');
    }
});
Horse
  • 3,023
  • 5
  • 38
  • 65
  • That's a very good answer. Thanks. But unfortunately I was look for a google static images not the panoramas. Sorry for the confusion if there were any. But I'll give you a vote up since it might help to some other who don't mind getting the panorama. Thanks again. – Ruchira Apr 29 '15 at 22:54
-1

Without further information such as code snippet or at least programming language, it will be difficult to provide a concrete example.

Assuming that you are using PHP, you can use PHP's getimagesize() function to get the size of the image. Simply replace the URL in the example with your Street View request URL.

HTTP Header

You can also check the HTTP Header for response size. Check the Content-Length field. For example in Java

new DataOutputStream(response.getOutputStream()).size();
Community
  • 1
  • 1
  • Well, there is no programming language involved as it's just a simple GET request. As to answer your question regarding the code snippet, I'm simply setting the URL I've already provided in my question to a tag. I know how to check the image size and I'm not asking that. I'm asking what's the better way to do that without checking the image size. – Ruchira Jun 05 '14 at 03:54