来自 Lon Lat 的 Google Maps Api StreetView PanoramaOptions Point of View Setting [英] Google Maps Api StreetView PanoramaOptions Point of View Setting from Lon Lat

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

问题描述

我有一个由我的 Lat Lng 坐标标识的 StreetViewPanorama.我的 Lat 和 Lng 坐标并不完全在 Google 汽车拍摄照片的道路上,但它们位于我想在街景图片中看到的建筑物的中心.所以我有两个坐标,我认为可以计算 POV 度以获得建筑物的正确镜头.我需要的是如何获得自动放置男人"的点的经纬度,以便我可以计算出正确的 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.

推荐答案

问题解决:

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

这篇关于来自 Lon Lat 的 Google Maps Api StreetView PanoramaOptions Point of View Setting的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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