javascript - 如何修复错误:无法读取未定义的属性“mapmatching”
问题描述
我在本地使用 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'”
解决方案
推荐阅读
- javascript - jQuery AJAX POST 到 PHP 有效,XMLHttpRequest 无效
- algorithm - 具有两种成本的有向无环图中的最短路径
- python - 使用 Python 解析频率分布图的嵌套行文本文档
- docker - Docker 挂载点是如何决定的?
- html - VBA Excel IE自动化:通过自定义标签定位元素
- nlp - seq2seq model 转换器模型 - 批量化我的输入的最佳方法是什么?
- r - 使用精确匹配和模糊匹配在 R 中加入两个大型数据集
- c++ - 为什么我得到一个运行时错误,它说可变长度数组绑定评估为非正值 0?
- android - 使用存储访问框架的自定义文件夹图标不显示
- python - 使用布尔逻辑基于多个条件过滤数据帧