admin管理员组文章数量:1318988
I have a Google map and street view based on provided lat/lng coordinates, zoom, yaw and pitch. I need to invoke a javascript to update a hidden field for each of these values whenever any of the details change from their default or when a button is clicked.
So whenever the map/street view is zoomed in, panned, tilted etc it outputs the new details.
How do I call the functions getPOV(), yawchanged(yaw:Number), pitchchanged(pitch:Number), and zoomchanged(zoom:Number) whenever the Street View is changed (similar to moveend for Maps)
I have a Google map and street view based on provided lat/lng coordinates, zoom, yaw and pitch. I need to invoke a javascript to update a hidden field for each of these values whenever any of the details change from their default or when a button is clicked.
So whenever the map/street view is zoomed in, panned, tilted etc it outputs the new details.
How do I call the functions getPOV(), yawchanged(yaw:Number), pitchchanged(pitch:Number), and zoomchanged(zoom:Number) whenever the Street View is changed (similar to moveend for Maps)
Share Improve this question edited Apr 15, 2009 at 0:57 Peter Craig asked Apr 8, 2009 at 14:59 Peter CraigPeter Craig 7,28919 gold badges63 silver badges74 bronze badges3 Answers
Reset to default 4Not sure of the best way to press this but this works to get the changed details:
GEvent.addListener(myPano, 'initialized', function(pano) {
alert("newlng: " + pano.latlng.lng() + ", newlat: " + pano.latlng.lat());
});
GEvent.addListener(myPano, 'yawchanged', function(newyaw){
alert("yawchanged: " + newyaw);
});
GEvent.addListener(myPano, 'pitchchanged', function(newpitch) {
alert("pitchchanged: " + newpitch);
});
GEvent.addListener(myPano, 'zoomchanged', function(newzoom) {
alert("zoomchanged: " + newzoom);
});
I generally have found that "moveend" is the best event to use as a hook to get the state of the map when a user changes it. I will need to look up how to get the lat/lng, zoom, yaw, and pitch from the map isntanct when I have more time this afternoon
// map is the instance of your GMap2
GEvent.addListener(map, 'moveend', function() {
var center = map.getCenter();
var zoom = map.getZoom();
alert([center.lat(), center.lng(), zoom].join(','));
});
For google maps api v3... Assuming you have a streetView map already loaded named "panorama"
google.maps.event.addListener(panorama, "pov_changed", function() {
var panoInfo = panorama.getPov();
var thePitch = panoInfo['pitch'];
var isHeading = panoInfo['heading'];
var theZoom = panoInfo['zoom'];
});
本文标签: javascriptGetting latlngzoomyawpitch from Google Street ViewStack Overflow
版权声明:本文标题:javascript - Getting latlngzoomyawpitch from Google Street View - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742054369a2418208.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论