I'm working on proof-of-concept application using Google Maps V3 API. I have a database with a list of all cities and their center points in (lat
,lng
) format. When I open a random city from the database, the map is centered to the center point and switches to Street View view.
The problem is: sometimes there are user submitted photos and no "walk" feature in this case. Here is an example of such a photo which is also a part of Street View layer:
Is there a way to avoid these user photos and are they different from Google Maps API standpoint from the real photos made by Google drivers with "walk" feature? I need a way to skip to the next nearest point with "proper" Street View photo from a Google car.
Another question: is there a way/algorithm to find the nearest street view point to the coordinates given?
Here is the current code snippet:
var point = new google.maps.LatLng(data[0].lat, data[0].lng);
var webService = new google.maps.StreetViewService();
var checkaround = 5000;
webService.getPanoramaByLocation(point,checkaround ,function(panoData) {
if(panoData){
if(panoData.location){
if(panoData.location.latLng){
window.map.setCenter(panoData.location.latLng);
window.map.setZoom(14);
var panoramaOptions = {
position: panoData.location.latLng,
pov: {
heading: 34,
pitch: 10
}
};
var panorama = new google.maps.StreetViewPanorama(document.getElementById('pano'), panoramaOptions);
map.setStreetView(panorama);
}
}
}
});
I can't publish it on jsfiddle as there is a php backend with database, but with the code above and a test point (lat
,lng
) = (54.226978, 49.568459) you can recreate the problem, you'll see the photo and not the Street View. However, this city and this very point is covered by Street View.
The problem might be that your calling
getPanoramaByLocation()
. It might work if you omit that, and just do this:Or if you want to
getPanoramaByLocation()
you should callsetPano()
in the callback like this: