【问题标题】:Google Maps Api StreetView PanoramaOptions Point of View Setting from Lon LatGoogle Maps Api Street View Panorama Options Point of View Setting from Lon Lat
【发布时间】:2013-05-08 14:25:44
【问题描述】:

我有一个由我的 Lat Lng 坐标识别的 StreetViewPanorama。 我的纬度和纬度坐标并不完全位于谷歌汽车拍摄照片的道路上,但它们位于我想在街景照片中看到的建筑物的中心。 所以我有两个坐标,我认为可以计算 POV 度以获得建筑物的正确拍摄。 我需要的是如何获取自动放置“人”的点的经纬度,以便我可以计算正确的 POV 度数。

【问题讨论】:

标签: google-maps-api-3 options google-street-view


【解决方案1】:

我对 kiks73 解决方案的实现。

确保在加载地图 api 时添加几何库:

https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=visualization,places,geometry&sensor=true

var dist = 50;

service.getPanoramaByLocation(targetLatLng, dist, function(panoData){
    panoramaLatLng = panoData.location.latLng;
    initStreetView(targetLatLng, panoramaLatLng)    
});

function initStreetView(targetLatLng, panoramaLatLng){

    var panoramaOptions = {
        position: targetLatLng
    };

    var streetView = new google.maps.StreetViewPanorama(document.getElementById('streetView'),panoramaOptions);
    var heading = google.maps.geometry.spherical.computeHeading(panoramaLatLng, targetLatLng);
    map.setStreetView(streetView);      
    streetView.setPov({heading:heading, pitch:0});                  

}               

【讨论】:

    【解决方案2】:

    问题解决了:

    // d is the position of the house or fisical element where I want to point the view
    var d = {lat: 43.538524840485, lng: 10.322718769311};
    var whereToLookLatLng = new google.maps.LatLng(parseFloat(d.lat), parseFloat(d.lng));
    var panorama = new google.maps.StreetViewPanorama(
        document.getElementById('pano'),
        panoramaOptions
    );
    map.setStreetView(panorama);
    
    var service = new google.maps.StreetViewService;
    // With this function I get the panorama, if available, next the house or fisical element where I want to point the view 
    service.getPanoramaByLocation(panorama.getPosition(), 50, 
        function(panoData) {
            if (panoData != null) {
                // MamLatLng is the position of the point of view
                var ManLatLng = panoData.location.latLng;
                // Now I calculate the heading to point the view in the direction of whereToLookLatLng
                var heading = google.maps.geometry.spherical.computeHeading(ManLatLng, whereToLookLatLng);
                var pov = panorama.getPov();
                pov.heading = heading;
                panorama.setPov(pov);
            }
        });
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多