首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Mapillary :如何激活/禁用方向箭头

问Mapillary :如何激活/禁用方向箭头
EN

Stack Overflow用户
提问于 2017-05-23 20:58:31
回答 1查看 103关注 0票数 0

我需要激活/禁用在Mapillary上构建的web应用程序中Mapillary上的方向箭头。

我试过构建一个代码样本来解释.

这是密码

代码语言:javascript
复制
<html>
<head>
    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

    <script src='https://unpkg.com/mapillary-js@2.5.0/dist/mapillary.min.js'></script>
    <link href='https://unpkg.com/mapillary-js@2.5.0/dist/mapillary.min.css' rel='stylesheet' />

    <style>
        html, body { margin: 0; padding: 0; height: 100%; }
    </style>
</head>

<body>
  <div id="titlebar">
    <center>
        Select option:
        <select onchange="onSelect.call(this, event)">
          <option value="with">With arrows</option>
          <option value="without">Without arrows</option>
        </select>
    </center>
  </div>

  <div id="xxx">
     <table border=1>
      <div id="mly"  style="width:100%;height:100%">
      </div>
     </table>
  </div>

  <script>
        var pegman_position = {lat: 42.628386111111126, lng: 13.291408333333237};
        var mly = new Mapillary.Viewer(
            'mly',
            // Replace this with your own client ID from mapillary.com
            'QjI1NnU0aG5FZFZISE56U3R5aWN4ZzowODkzY2RjNjM1ZmEwYTVi',
            'Sx1k3lLpdFU1TWS-8u_Y-w',
            {
                component: {
                    cover: false,
                    direction: false
                }
            }
        );

        mly.setCenter(pegman_position.lat, pegman_position.lon);

        // Viewer size is dynamic so resize should be called every time the window size changes
        window.addEventListener("resize", function() { mly.resize(); });

        function onSelect(event) {
            switch (this.options[this.selectedIndex].text) {
               case "With arrows":
                 var theComponent = mly.getComponent('direction');
                 theComponent.configure({direction: true});
                 break;
               case "Without arrows":
                 break;
              }
        }

  </script>
</body>
</html>

如您所见,最初的情况是没有方向箭头,因为我从这个配置开始。

代码语言:javascript
复制
           {
                component: {
                    cover: false,
                    direction: false
                }
            }

我想用图片上方的选择来修改它,如果我选择“带箭头”,我想显示箭头.

我试过用这个代码来处理这种情况.

代码语言:javascript
复制
              case "With arrows":
                 var theComponent = mly.getComponent('direction');
                 theComponent.configure({direction: true});
                 break;

执行时没有错误,但在我的地图上没有任何变化.

建议/例子?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-24 15:22:53

我用这种方式解决了..。

代码语言:javascript
复制
<html>
<head>
    <meta charset='utf-8' />
    <title></title>
    <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

    <script src='https://unpkg.com/mapillary-js@2.5.0/dist/mapillary.min.js'></script>
    <link href='https://unpkg.com/mapillary-js@2.5.0/dist/mapillary.min.css' rel='stylesheet' />

    <style>
        html, body { margin: 0; padding: 0; height: 100%; }
    </style>
</head>

<body>
  <div id="titlebar">
    <center>
        Select option:
        <select onchange="onSelect.call(this, event)">
          <option value="with">With arrows</option>
          <option value="without">Without arrows</option>
        </select>
    </center>
  </div>

  <div id="xxx">
     <table border=1>
      <div id="mly"  style="width:100%;height:100%">
      </div>
     </table>
  </div>

  <script>
        var pegman_position = {lat: 42.628386111111126, lng: 13.291408333333237};
        var mly = new Mapillary.Viewer(
            'mly',
            // Replace this with your own client ID from mapillary.com
            'QjI1NnU0aG5FZFZISE56U3R5aWN4ZzowODkzY2RjNjM1ZmEwYTVi',
            'Sx1k3lLpdFU1TWS-8u_Y-w',
            {
                component: {
                    cover: false
                }
            }
        );

        mly.setCenter(pegman_position.lat, pegman_position.lon);

        // Viewer size is dynamic so resize should be called every time the window size changes
        window.addEventListener("resize", function() { mly.resize(); });

        function onSelect(event) {
            switch (this.options[this.selectedIndex].text) {
               case "With arrows":
                 mly.activateComponent("direction");
                 mly.activateComponent("sequence");
                 break;
               case "Without arrows":
                 mly.deactivateComponent("direction");
                 mly.deactivateComponent("sequence");
                 break;
              }
        }

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

https://stackoverflow.com/questions/44144887

复制
相关文章

相似问题

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