标记未使用Mapbox GL JS API显示

时间:2017-06-09 22:33:35

标签: mapbox mapbox-gl

我跟随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>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)