有没有办法让gmaps4rails在街景中打开地图?

时间:2012-06-04 03:50:17

标签: ruby-on-rails google-maps gmaps4rails google-street-view

我尝试过更改缩放级别,但它始终保持在地图模式下。无法在wiki上找到任何信息。任何帮助或其他建议将不胜感激。

1 个答案:

答案 0 :(得分:5)

仅使用Google的Javascript API即可结束。它是这样的:

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