如何在 mapbox-gl-js 中使用 Mapbox Mapmatching API 输出?
How to use Mapbox Mapmatching API output with mapbox-gl-js?
我对此很陌生,真的需要指导,
我知道使用 Mapbox 地图匹配 API,我将得到正确位置的原始输出,但我不明白的是,我如何使用 mapbox 地图匹配 API 输出mapbox-gl-js 创建正确的地图?
我需要为此使用 mapbox-match-js 吗?如果是,我如何通过 geo json?
https://github.com/mapbox/mapbox-match.js/tree/master
L.mapbox.mapmatching(geojson, options, function (error, layer) {
layer.addTo(map);
layer.setStyle({
color: '#9a0202',
weight: 4,
opacity: 0.8
});
});
这里有一个演示html,但是原始输出与地图匹配API输出不同,
有人可以帮我解决这个问题吗?
感谢您的帮助。
我遇到了同样的问题,这是我的解决方案:
1) 在我的 index.html
文件中添加 <script src="https://unpkg.com/mapbox@1.0.0-beta7/dist/mapbox-sdk.js"></script>
。
2) 使用mapbox.matching:
var mapboxClient = new MapboxClient(mapboxgl.accessToken);
mapboxClient.matching(
// dataToAddLine: array like:
// [
// [13.418805122375488, 52.50059890747071],
// [13.419144630432129, 52.50109481811523]
// ]
dataToAddLine.features[0].geometry.coordinates
, function(err, res) {
// do something with res
console.log(res);
}
)
您可以在此处测试资源坐标:geojson
我希望这个解决方案也能帮到你。
我对此很陌生,真的需要指导,
我知道使用 Mapbox 地图匹配 API,我将得到正确位置的原始输出,但我不明白的是,我如何使用 mapbox 地图匹配 API 输出mapbox-gl-js 创建正确的地图?
我需要为此使用 mapbox-match-js 吗?如果是,我如何通过 geo json?
https://github.com/mapbox/mapbox-match.js/tree/master
L.mapbox.mapmatching(geojson, options, function (error, layer) {
layer.addTo(map);
layer.setStyle({
color: '#9a0202',
weight: 4,
opacity: 0.8
});
});
这里有一个演示html,但是原始输出与地图匹配API输出不同,
有人可以帮我解决这个问题吗?
感谢您的帮助。
我遇到了同样的问题,这是我的解决方案:
1) 在我的 index.html
文件中添加 <script src="https://unpkg.com/mapbox@1.0.0-beta7/dist/mapbox-sdk.js"></script>
。
2) 使用mapbox.matching:
var mapboxClient = new MapboxClient(mapboxgl.accessToken);
mapboxClient.matching(
// dataToAddLine: array like:
// [
// [13.418805122375488, 52.50059890747071],
// [13.419144630432129, 52.50109481811523]
// ]
dataToAddLine.features[0].geometry.coordinates
, function(err, res) {
// do something with res
console.log(res);
}
)
您可以在此处测试资源坐标:geojson
我希望这个解决方案也能帮到你。