Any way to have gmaps4rails open the map in Street View?

自古美人都是妖i 提交于 2019-12-22 10:57:24

问题


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


来源:https://stackoverflow.com/questions/10876121/any-way-to-have-gmaps4rails-open-the-map-in-street-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!