Google Maps Api StreetView PanoramaOptions从Lon Lat的角度设置 [英] Google Maps Api StreetView PanoramaOptions Point of View Setting from Lon Lat

查看:315
本文介绍了Google Maps Api StreetView PanoramaOptions从Lon Lat的角度设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



  // d是房子的位置或fisical元素,我想指向视图
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;
//使用这个函数,我得到全景图,如果可用的话,接下来我要指向视图的房子或fisical元素
service.getPanoramaByLocation(panorama.getPosition(),50,
函数(panoData){
if(panoData!= null){
// MamLatLng是视角的位置
var ManLatLng = panoData.location.latLng;
/ /现在我计算标题以指向视图的方向whereToLookLatLng
var heading = google.maps.geometry.spherical.computeHeading(ManLatLng,whereToLookLatLng);
var pov = panorama.getPov();
pov.heading = heading;
panorama.setPov(pov);
}
});
}


I've got a StreetViewPanorama identified by my Lat Lng coordinates. My Lat and Lng coordinates are not exactly on the road from which Google car took the picture, but they are in the center of the building that I want to see in StreetView's picture. So I have 2 couple of coordinates, and I think that it's possible to calculate POV degrees to obtain a correct shot of the building. What I need is how to get the Lon Lat of the point in which is automatically placed "the man", so that I can calculate the correct POV degrees.

解决方案

Problem solved:

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

这篇关于Google Maps Api StreetView PanoramaOptions从Lon Lat的角度设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆