Search code examples
google-mapsgoogle-places-apigoogle-street-view

How DO I change the street view result after searching using places API


I'm trying to change my split view streetview/maps screen to the result of a search in a places text field. The maps changes to the location, but I have been unable to get the street view to change tot he same address/location. Any help is appreciated.

what I've done is as follows and it's not working:

if (place.geometry.viewport) {
        map.fitBounds(place.geometry.viewport);

        var newpano = map.getStreetView();
        newpano.setPano(place.location.pano);
        newpano.setVisible(true);

Solution

  • Places API does not provide Street View panos, there is no place.location.pano

    You can use send Street View Service Requests from JavaScript, to find the nearest pano to the place.geometry.location (latlng), and pass that on to setPano()

    You may also be interested in: Issue 6033: Feature Request: Business Tour