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?
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.
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.
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.
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.
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
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With