Lat Lng 座標で識別される StreetViewPanorama があります。私の緯度と経度の座標は、Google カーが写真を撮った道路と正確には一致しませんが、ストリートビューの写真で見たい建物の中心にあります。したがって、2 つの座標があり、建物の正しいショットを取得するために POV 度を計算することは可能だと思います。私が必要とするのは、正しい POV 度を計算できるように、自動的に「男」が配置されるポイントの経度を取得する方法です。
4349 次
2 に答える
3
kiks73 のソリューションの私の実装。
Maps 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});
}
于 2013-09-16T08:52:17.750 に答える
3
問題が解決しました:
// 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);
}
});
}
于 2013-05-09T15:09:48.747 に答える