Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if Google StreetView is available in an address/coordinates

I'm making an app that uses the Google Street View Image API

I have no problem getting an image of the street view based on the address/coordinates

but - I want to detect if the specific address has a Street View image available (in order to show a different behavior for addresses that doesn't have it)

The only idea I got so far is to read the pixels of the returned image and detect whether this is the image the I got when there is no image available

Any other idea?

Thanks!

like image 248
Yaron U. Avatar asked Nov 05 '12 16:11

Yaron U.


People also ask

Is Google Street View everywhere?

Google Street View is a technology featured in Google Maps and Google Earth that provides interactive panoramas from positions along many streets in the world. It was launched in 2007 in several cities in the United States, and has since expanded to include cities and rural areas worldwide.

Can I see live Street View?

You can use Live View navigation during the walking portion of any type of trip. In the search bar, enter a destination or tap it on the map. Follow the on-screen instructions to help Maps find your location. Tip: Point your phone camera at buildings and signs across the street, instead of trees and people.


2 Answers

Using google.maps.StreetViewService.getPanoramaByLocation( latlng, radius, callback()), you can check whether there is a streetview panorama. If there is a streetview panorama, then there must be an image of streetview.

You can refer the reference of google : https://developers.google.com/maps/documentation/javascript/reference#StreetViewService

Or refer to the example of StreetViewService : https://google-developers.appspot.com/maps/documentation/javascript/examples/streetview-service

like image 77
user1852570 Avatar answered Sep 27 '22 21:09

user1852570


Google has an api endpoint where you can look up the metadata for a panorama/streetview:

https://maps.googleapis.com/maps/api/streetview/metadata?key=YOUR_API_KEY&location=STRING_ADDRESS_OR_LAT_LNG_COORDINATES

You can check the status property of the response.

Successful Response

{
   "copyright" : "© 2017 Google",
   "date" : "2016-05",
   "location" : {
      "lat" : 48.85783227207914,
      "lng" : 2.295226175151347
   },
   "pano_id" : "tu510ie_z4ptBZYo2BGEJg",
   "status" : "OK"
}

Failed Response

{
   "status" : "ZERO_RESULTS"
}

@see https://developers.google.com/maps/documentation/streetview/metadata

like image 41
TrieuNomad Avatar answered Sep 27 '22 21:09

TrieuNomad