首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从谷歌街景的原始全景向北走

从谷歌街景的原始全景向北走
EN

Stack Overflow用户
提问于 2016-11-30 21:26:38
回答 2查看 1.4K关注 0票数 9

我在一个项目中使用街景Javascript Api,我理解如何使用标题使谷歌的全景图向北。

现在,我也得到了所有的瓷砖,创造了这个全景图,并使用它们来创建一个360°原始全景图像。

然而,我想知道是否有一种方法可以自动找出北方在原始全景图中的位置。

例如,

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-19 21:18:51

我设法解决了这个问题。

在我的项目中,我使用StreetViewService从一对纬度-经度获得全景图

代码语言:javascript
运行
复制
sv = new google.maps.StreetViewService();
sv.getPanorama({location: latLng, radius: 50}, updateInfo)

sv.getPanorama的响应updateInfo (info,status)的参数中,我发现:

代码语言:javascript
运行
复制
info.tiles.centerHeading

这是车的方向。

现在,如果原始全景图是一个360°的视图,我可以使用交叉乘法得到水平位置的像素,并正确地绘制所有的基数。

这比我想要的要复杂得多,但至少现在起作用了。

票数 4
EN

Stack Overflow用户

发布于 2017-01-16 16:03:26

有直接的解决办法吗?

据我所知,Google,特别是全景视图,并没有像你在文章中那样在图片的北部和/或南部有箭头的界面。

这样的解决方案必须由您手工编码才能计算出来。

周旋

然而,有一个解决办法,您可以使用,它使用全景视图,并有一个内置的指南针在界面。这样,当你移动图像时,你总是能感觉到南北的位置。

代码和文档

您可以使用以下示例(PS:替换API键!)来实现这种类型的接口:

代码语言:javascript
运行
复制
<!DOCTYPE html>
<html>
  <head>
    <title>Custom Street View panoramas</title>
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      function initPano() {
        // Set up Street View and initially set it visible. Register the
        // custom panorama provider function. Set the StreetView to display
        // the custom panorama 'reception' which we check for below.
        var panorama = new google.maps.StreetViewPanorama(
          document.getElementById('map'), {
            pano: 'reception',
            visible: true,
            panoProvider: getCustomPanorama
        });
      }

      // Return a pano image given the panoID.
      function getCustomPanoramaTileUrl(pano, zoom, tileX, tileY) {
        // Note: robust custom panorama methods would require tiled pano data.
        // Here we're just using a single tile, set to the tile size and equal
        // to the pano "world" size.
        return 'https://developers.google.com/maps/documentation/javascript/examples/full/images/panoReception1024-0.jpg';
      }

      // Construct the appropriate StreetViewPanoramaData given
      // the passed pano IDs.
      function getCustomPanorama(pano, zoom, tileX, tileY) {
        if (pano === 'reception') {
          return {
            location: {
              pano: 'reception',
              description: 'Google Sydney - Reception'
            },
            links: [],
            // The text for the copyright control.
            copyright: 'Imagery (c) 2010 Google',
            // The definition of the tiles for this panorama.
            tiles: {
              tileSize: new google.maps.Size(1024, 512),
              worldSize: new google.maps.Size(1024, 512),
              // The heading in degrees at the origin of the panorama
              // tile set.
              centerHeading: 105,
              getTileUrl: getCustomPanoramaTileUrl
            }
          };
        }
      }
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initPano">
    </script>
  </body>
</html>

它可以在自定义街景全景文档页面上找到。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40898512

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档