Request basic StreetView road / bypass panoramas instead of back API malls

Is there a way to request the main road panorama of Google StreetView instead of back panel panorama data for a given location (latitude / longitude)?

I use the Google Maps Javascript API to get a street view panorama from the home address provided by our users. It works very well for most of the addresses I tried, but I notice that many properties in California also look like streets for the back alleys, and the API seams consistently return a panorama of the back alley instead of the main road (in front of the property).

I do not want to show the user the back alley of the panorama of my house, but instead the main panorama of the road. If I look at the same address on maps.google.com, I see the front of the house, but when I request the same address through the API, I get the back alley.

I am currently using the following process:

  • Geocode Address
  • Get a panorama based on the location of the geocode (lat / long)
  • Calculate the title and panorama on the page

Test addresses:

  • 325 S Peck Dr, Beverly Hills, CA, USA, 90212
  • 333 S Rodeo Dr, Beverly Hills, CA, USA, 90212

Any ideas or suggestions would be greatly appreciated. Thanks!

+5
source share
1 answer

Use the route service to get directions from your desired address. Use this location instead of the geocoder result for a street view location. Use the result of the geocoder (I hope the result of the accuracy of ROOFTOP) for the place you want to look at.

Related question: Collision with the target building using Google StreetView Examples:

code snippet:

var sv = new google.maps.StreetViewService(); var geocoder = new google.maps.Geocoder(); var directionsService = new google.maps.DirectionsService(); var panorama; var address = "333 S Rodeo Dr, Beverly Hills, CA, USA, 90212"; var myLatLng; function initialize() { panorama = new google.maps.StreetViewPanorama(document.getElementById("pano")); geocoder.geocode({ 'address': address }, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { myLatLng = results[0].geometry.location; // find a Streetview location on the road var request = { origin: address, destination: address, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, directionsCallback); } else { alert("Geocode was not successful for the following reason: " + status); } }); } google.maps.event.addDomListener(window, 'load', initialize); function processSVData(data, status) { if (status == google.maps.StreetViewStatus.OK) { panorama.setPano(data.location.pano); var heading = google.maps.geometry.spherical.computeHeading(data.location.latLng, myLatLng); panorama.setPov({ heading: heading, pitch: 0, zoom: 1 }); panorama.setVisible(true); } else { alert("Street View data not found for this location."); } } function directionsCallback(response, status) { if (status == google.maps.DirectionsStatus.OK) { var latlng = response.routes[0].legs[0].start_location; sv.getPanoramaByLocation(latlng, 50, processSVData); } else { alert("Directions service not successfull for the following reason:" + status); } } 
 <script src="https://maps.googleapis.com/maps/api/js?libraries=geometry&key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script> <div id="pano" style="width: 425px; height: 400px;float:left"></div> 
+7
source

All Articles