Mapillary JS:如何激活/停用方向箭头

时间:2017-05-23 20:58:31

标签: javascript html

我需要在Mapillary JS构建的Web应用程序中激活/停用Mapillary图像上的方向箭头。

我试图构建一个小代码示例来解释....

这里是你的代码

<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>

初始情况是没有方向箭头,因为我从这个配置开始

           {
                component: {
                    cover: false,
                    direction: false
                }
            }

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

我试图用这段代码管理这种情况......

              case "With arrows":
                 var theComponent = mly.getComponent('direction');
                 theComponent.configure({direction: true});
                 break;

执行没有错误,但我的Mapillary图像没有变化......

建议/示例?

1 个答案:

答案 0 :(得分:0)

我已经用这种方式解决了......

from django.db.models import Count
given_results =  ResultValue.objects.filter(person=person).values('program__name').annotate(total=Count('*'))