Mapbox GL-JS - 为什么我不能显示路线对话框?
Mapbox GL-JS - Why can't I display the directions dialog box?
我想使用 this Mapbox example from the documentation 将 Mapbox 方向添加到我的地图,但方向不显示。需要明确的是,这是没有出现的内容:
我的代码很简单,直接取自例子:
map.addControl(
new MapboxDirections({
accessToken: mapboxgl.accessToken
}),
'top-left'
);
我是否有某种语法错误?我已经尝试在几个不同的函数中添加代码以确保它正在执行,并且我的地图的其余部分工作 - 我的 API 键是好的并且我的地图被命名为 "map",就像在例子。如果这不是语法问题,我知道我的页面上存在一些 z-index 问题。如果是这种情况,我将如何访问 CSS 中的这个元素?调用的时候可能躲在我的地图后面什么的。
MapboxDirections 控件要求在 header - javascript 和 CSS 中包含以下内容:
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.0.2/mapbox-gl-directions.js"></script>
<link
rel="stylesheet"
href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.0.2/mapbox-gl-directions.css"
type="text/css"
/>
我想使用 this Mapbox example from the documentation 将 Mapbox 方向添加到我的地图,但方向不显示。需要明确的是,这是没有出现的内容:
我的代码很简单,直接取自例子:
map.addControl(
new MapboxDirections({
accessToken: mapboxgl.accessToken
}),
'top-left'
);
我是否有某种语法错误?我已经尝试在几个不同的函数中添加代码以确保它正在执行,并且我的地图的其余部分工作 - 我的 API 键是好的并且我的地图被命名为 "map",就像在例子。如果这不是语法问题,我知道我的页面上存在一些 z-index 问题。如果是这种情况,我将如何访问 CSS 中的这个元素?调用的时候可能躲在我的地图后面什么的。
MapboxDirections 控件要求在 header - javascript 和 CSS 中包含以下内容:
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.0.2/mapbox-gl-directions.js"></script>
<link
rel="stylesheet"
href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.0.2/mapbox-gl-directions.css"
type="text/css"
/>