如何解决错误:无法读取未定义的属性“ mapmatching”

时间:2019-07-18 08:38:21

标签: javascript mapbox

我在本地使用mapbox-match.js而不使用http请求来匹配map上的路线。但我在匹配和错误消息

时遇到问题
  

“无法读取未定义的属性'mapmatching'

显示。如何解决呢?

这是用于使用本地宿主地图进行地图可视化。运行http服务器,html和javascript。我使用d3-js和mapbox将坐标集渲染为地图上的geojson数据,以可视化路线

<head>
  <meta charset='utf-8' />
  <script src='MAPBOX/mapbox-gl.js'></script>
  <link href='MAPBOX/mapbox-gl.css' rel='stylesheet' />
  <script src='mapbox.js-publisher-production/src/mapbox.js'></script>
  <script src='mapbox-match.js-master/src/match.js'></script>
</head>

<body>
  <script>
    function updateRoute(newCoords) {
      // Set the profile
      var profile = "driving";
      L.mapbox.mapmatching(Coords, profile);
    }

    L.mapbox.mapmatching(Coords, profile, function(error, layer) {

      layer.addTo(map);
      layer.setStyle({
        color: '#9a0202',
        weight: 4,
        opacity: 0.8
      });

      layer.addLayer({
        "id": "route",
        "type": "line",
        "source": {
          "type": "geojson",
          "data": {
            "type": "Feature",
            "properties": {},
            "geometry": coords
          }
        },
        "layout": {
          "line-join": "round",
          "line-cap": "round"
        },
        "paint": {
          "line-color": "#33C9EB",
          "line-width": 3
        }

      });
    });
    }
  </script>
</body>

调试代码后,错误显示为“ TypeError:无法读取未定义的属性'mapmatching'”

0 个答案:

没有答案