Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 谷歌地图Api街景全景选项Lon Lat的视点设置_Google Maps Api 3_Options_Google Street View - Fatal编程技术网

Google maps api 3 谷歌地图Api街景全景选项Lon Lat的视点设置

Google maps api 3 谷歌地图Api街景全景选项Lon Lat的视点设置,google-maps-api-3,options,google-street-view,Google Maps Api 3,Options,Google Street View,我有一张街景全景图,由我的横向坐标来识别。 我的Lat和Lng坐标并不完全在谷歌汽车拍摄照片的道路上,但它们位于我想在街景图片中看到的建筑物的中心。 所以我有两个坐标,我认为可以计算出POV角度来获得建筑物的正确照片。 我需要的是如何获得自动放置“人”的点的经度,以便计算正确的POV度。问题解决: // d is the position of the house or fisical element where I want to point the view var d = {lat: 43

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

问题解决:

// 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);
        }
    });
}
解决的问题:

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

我对kiks73解决方案的实现

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

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


我对kiks73解决方案的实现

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

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

“摄像头”的位置是panorama getPosition方法返回的latLng:“摄像头”的位置是panorama getPosition方法返回的latLng: