从 Google 街景获取 lat/lng/zoom/yaw/pitch

发布于 2024-07-16 04:04:18 字数 269 浏览 6 评论 0原文

我有一个基于提供的纬度/经度坐标、缩放、偏航和俯仰的谷歌地图和街景。 每当任何详细信息从默认值更改或单击按钮时,我都需要调用 JavaScript 来更新每个值的隐藏字段。

因此,每当地图/街景视图被放大、平移、倾斜等时,它都会输出新的细节。

每当街景视图更改时,如何调用函数 getPOV()、yawchanged(yaw:Number)、pitchchanged(pitch:Number) 和 Zoomchanged(zoom:Number)(类似于地图的 moveend)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫竹語嫣☆ 2024-07-23 04:04:18

不确定压缩它的最佳方法,但这可以获取更改的详细信息:

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

Not sure of the best way to compress 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);
});
帅的被狗咬 2024-07-23 04:04:18

我通常发现“moveend”是用作钩子的最佳事件,用于在用户更改地图时获取地图的状态。 当我今天下午有更多时间时,我需要查找如何从地图中获取纬度/经度、缩放、偏航和俯仰角

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

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(','));
});
感悟人生的甜 2024-07-23 04:04:18

对于谷歌地图 API v3...假设您已经加载了名为“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'];
});

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'];
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文