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

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
    }
});

Leave a Comment