我有一个由Lat Lng坐标标识的StreetViewPanorama。 我的Lat和Lng坐标并不完全位于Google汽车拍摄照片的道路上,但他们位于我想在StreetView的照片中看到的建筑的中心。 所以我有两个坐标,我认为可以计算POV度以获得正确的建筑物照片。 我需要的是如何获得自动放置“男人”的点的Lon Lat,以便我可以计算出正确的POV度。Google Maps Api StreetView PanoramaOptions从Lon Lat的角度设置
0
A
回答
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);
}
});
}
3
我实现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});
}
相关问题
- 1. 从Google Maps链接中查找lon/lat
- 2. Google Streetview API
- 3. Google Maps API文本搜索位置
- 4. Google maps API watchPosition
- 5. THREE.js - Quaternion to lat,lon
- 6. 使用Google地图API计算两分之差X分钟的位置(lat,lon)?
- 7. lon,lat到时区
- 8. 从Google Maps API切换到Here Maps API
- 9. 使用Google Maps JavaScript API V3检查StreetView的可用性
- 10. Google Maps API v3街景“google未定义”
- 11. Google Maps API。投影
- 12. Google Maps API - Marker Clusterer
- 13. Google Maps API设置图标大小
- 14. 从google streetview拍照
- 15. google-maps-api-3
- 16. Grails + Google Maps API
- 17. Google StreetView快照
- 18. 将Lat/Lon转换为MGRS
- 19. Google Maps API OVER_QUERY_LIMIT
- 20. 给定IP或纬度/经度的Next&Nearest Google Streetview
- 21. 分配JSON字符串值的纬度和经度在google.maps.LatLng(LAT,LON)在MVC 4
- 22. 地理位置+ Google Maps API?
- 23. Google Maps API - 放置新针
- 24. Google地图API不会返回经纬度(或)lon()NAN
- 25. Google Maps API v2 vs Google Maps API v3?
- 26. zombie.js和Google Maps API
- 27. PHP - 从Google Maps API返回值
- 28. Google Maps API + Android位置数据
- 29. 在Google Maps API中使用JSON
- 30. Google Maps API v2街景标记图标
“相机”的位置是由全景为getPosition方法返回的经纬度:https://开头developers.google.com/maps/documentation/javascript/reference#StreetViewPanorama – geocodezip 2013-05-08 14:32:22