1

I know there are at least a couple of questions like this

detecting "we have no imagery" of google maps street view static images

How can I tell if Google's Streetview Image API Returns "Sorry, we have no imagery here" (ie. NULL) Result?

These articles offer a couple of solutions. The two most popular I've seen here and via Google searaches are:

  1. Detecting the size of the image to determine if you got a "good" image or not from the google static image API
  2. 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?

Community
  • 1
  • 1
Will
  • 11
  • 2
  • Since you are already loading up the JS api, why not use JS to show the map? Also, the documentation says 50 meters or less gives "the nearest to the location", so 50 is probably safe. – Jim Deville Mar 18 '13 at 20:33
  • Thank you Jim. I think I read the same documentation as you, but it was regarding the interactive/panorama API and so I wasn't sure if I could assume 50 meters in the StreetView JS services lined up with the closest possible image for the static API. Regarding using JS for the map, I couldn't find documentation for generating a static streetview image in JS. They seem to steer people towards the static API as far as I can tell – Will Mar 18 '13 at 20:42
  • yeah, they do steer towards static, but if you are already loading JS, then it might be worth loading it via JS, and disabling all interactive controls. One consideration is that you may be incurring 2 api calls by doing JS + image (one for the JS load, one for the image load) (https://developers.google.com/maps/faq#usage_mapload). Depending on the scale, that might become a cost issue. – Jim Deville Mar 18 '13 at 20:47
  • That's a very good point regarding the doubled hits against the Maps API. I'm going to try to implement a solution like you suggest and discuss my results here. – Will Mar 18 '13 at 21:06
  • I didn't realize that there is a separate 25000 quota for Streetview Image API/Static Maps API/Maps v3 API. The distinction is clear when I look at the API console https://code.google.com/apis/console. Thanks to the Reports in the console I determined that my "check" for imagery where I call getPanoramaByLocation does NOT count as a hit against any of my Maps/Streetview API quotas. I *would* change to exclusively use the JS API except that then I'd have to determine the heading/pov myself, which the static API does for me. I think I'll just chage my radius to 50 and call it a day. – Will Mar 25 '13 at 21:20
  • Possible duplicate of [How can I tell if Google's Streetview Image API Returns "Sorry, we have no imagery here" (ie. NULL) Result?](http://stackoverflow.com/questions/9795533/how-can-i-tell-if-googles-streetview-image-api-returns-sorry-we-have-no-image) – miguev Nov 25 '16 at 10:46
  • See http://stackoverflow.com/a/40803070/1069142 – miguev Nov 25 '16 at 10:47

0 Answers0