Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if Google Street View available and display message?

I am passing lat and lng variables and display google sreet view in a div. The problem is that when the StreetView is unavilable then nothing is displayed. I would like to check if there is a streetview for a given lat and lng and display a message. Here is my code:

var myPano = new GStreetviewPanorama(document.getElementById("street2"), panoOpts);
var location = new GLatLng(lat,lng)
myPano.setLocationAndPOV(location);

Maybe I should use something like: Event.addListener(myPano, "error", errorMessage());

Any ideas?

like image 726
Vonder Avatar asked Apr 20 '10 12:04

Vonder


People also ask

How do I know if Street View is available?

Use the yellow Pegman to explore the scene. Now that you think you've found the right spot, click the Pegman to reveal the blue lines which will indicate where Street View is available. Then, click on the place you want to view and the Pegman will “drop” you into Street View.

How do I check for Street View updates?

Google Street View Updates You can tell when Google Street View was updated in the bottom right of the screen. You should see a small box in the corner saying something like 'Image capture: May 2018'. This was when that particular scene was last updated.

Why is Google Street View not available?

The latest Google Maps updates may sometimes break certain features of the app, especially on Android or iOS. If this is the case for you, try reverting to an older app version. Or you can use Google Maps in offline mode to check if this solves the problem.

How often does Google update its Street View?

In general, Google tries to take new Street View photos in major cities once every year. Less populated areas can probably expect new photos every three years or so — but don't be surprised if it takes even longer.


1 Answers

In v3 this has changed a bit. Check out the documentation at http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewService

The updated code is:

var streetViewService = new google.maps.StreetViewService();
var STREETVIEW_MAX_DISTANCE = 100;
var latLng = new google.maps.LatLng(40.7140, -74.0062);
streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
    if (status === google.maps.StreetViewStatus.OK) {
        // ok
    } else {
        // no street view available in this range, or some error occurred
    }
});
like image 83
Arthur Clemens Avatar answered Sep 18 '22 07:09

Arthur Clemens