Google Street View heading issue

邮差的信 提交于 2019-12-01 08:40:38

问题


I'm working in a project where I need to show google map street view heading towards road.

I've set the heading: 0 for the panorama object. But for different location it shows the heading differently. for example in some cases it shows heading towards street, for some locations it shows heading towards home.

panorama = theMap.getStreetView();
panorama.setPosition(new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>););
panorama.setPov({
    heading: 0,
    zoom:1,
    pitch:0
});

If there any way can fix the heading towards street for all post codes?

Thanks


回答1:


Finally I found a very easy solution..

For the street view there's two links to navigate, that point towards street. I just read those heading and set the street view POV towards that direction. Here's full code.

var panoramaOptions = {
    position: langlongObj,
    visible: true
};
var panorama = new  google.maps.StreetViewPanorama(document.getElementById("map_canvas"), panoramaOptions);
map.setStreetView(panorama);

google.maps.event.addListener(panorama, 'links_changed', function() {
    var links =  panorama.getLinks();

    panorama.setPov({                   
        heading: links[0].heading,
        pitch: 0,
        zoom: 1
    });
});


来源:https://stackoverflow.com/questions/11900173/google-street-view-heading-issue

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