使用 Mapbox GL JS 不显示标记 API
Markers not appearing using the Mapbox GL JS API
我正在关注 these docs,但下面的代码没有呈现标记。有什么想法吗?
mapboxgl.accessToken = "pk.eyJ1IjoiZGlsbHBpeGVsIiwiYSI6ImNqM3A1YWV4czAwa3cyd3BmeWR4OTJ4NGEifQ.atNs-3fdoNghDcrdKwtIkA";
var map = new mapboxgl.Map({
container: "map",
center: [-74.50, 40],
zoom: 6,
scrollZoom: false,
style: "mapbox://styles/mapbox/light-v9",
});
map.addControl(new mapboxgl.NavigationControl(), "top-left");
var marker = new mapboxgl.Marker().setLngLat([-74.50, 40]).addTo(map);
#map {
height: 320px;
}
<link href="//api.mapbox.com/mapbox-gl-js/v0.36.0/mapbox-gl.css" rel="stylesheet"/>
<script src="//api.mapbox.com/mapbox-gl-js/v0.36.0/mapbox-gl.js"></script>
<div id="map"></div>
没关系。刚找到答案:https://github.com/mapbox/mapbox-gl-js/issues/4384
也在这里回答:
我正在关注 these docs,但下面的代码没有呈现标记。有什么想法吗?
mapboxgl.accessToken = "pk.eyJ1IjoiZGlsbHBpeGVsIiwiYSI6ImNqM3A1YWV4czAwa3cyd3BmeWR4OTJ4NGEifQ.atNs-3fdoNghDcrdKwtIkA";
var map = new mapboxgl.Map({
container: "map",
center: [-74.50, 40],
zoom: 6,
scrollZoom: false,
style: "mapbox://styles/mapbox/light-v9",
});
map.addControl(new mapboxgl.NavigationControl(), "top-left");
var marker = new mapboxgl.Marker().setLngLat([-74.50, 40]).addTo(map);
#map {
height: 320px;
}
<link href="//api.mapbox.com/mapbox-gl-js/v0.36.0/mapbox-gl.css" rel="stylesheet"/>
<script src="//api.mapbox.com/mapbox-gl-js/v0.36.0/mapbox-gl.js"></script>
<div id="map"></div>
没关系。刚找到答案:https://github.com/mapbox/mapbox-gl-js/issues/4384
也在这里回答: