Google Street View heading issue

后端 未结 1 1558
醉话见心
醉话见心 2021-01-15 09:18

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 locat

相关标签:
1条回答
  • 2021-01-15 09:42

    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
        });
    });
    
    0 讨论(0)
提交回复
热议问题