Any way to have gmaps4rails open the map in Street

2019-05-13 01:29发布

问题:

I've tried changing the zoom level, but it always stays in the map mode. Couldn't find any info on the wiki either. Any help or other suggestions would be appreciated.

回答1:

Ended up just using Google's Javascript API. It went something like this:

pos = new google.maps.LatLng( <%= latitude %>, <%= longitude %> );

var div = document.getElementById('streetViewContainer');
var sv = new google.maps.StreetViewPanorama(div);
sv.setPosition( pos );
sv.setVisible( true );

// find the heading by looking from the google car pos to the venue pos
var service = new google.maps.StreetViewService();
service.getPanoramaByLocation( pos, 50, function(result, status) {
    if (status == google.maps.StreetViewStatus.OK) 
    {   
        carPos = result.location.latLng;
        heading = google.maps.geometry.spherical.computeHeading( carPos, pos );
        sv.setPov( { heading: heading, pitch: 0, zoom: 1 } );
    }
} );