这会产生一个错误
leaflet.js:5 Uncaught TypeError: Cannot read property 'call' of undefined
<!-- Leaflet -->
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v1.0.0-beta.2/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet/v1.0.0-beta.2/leaflet.js"></script>
<!-- Mapbox GL -->
<link href="https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.3/mapbox-gl.css" rel='stylesheet' />
<script src="https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.3/mapbox-gl.js"></script>
mapboxgl.accessToken = YOUR_KEY;
var map = new mapboxgl.Map({
container: 'map',
style: YOUR_STYLE_URL
center: [0, 0],
zoom: 0
});
最佳答案
据我所知这是不可能的,但是 Mapbox.js(基于 Leaflet)从 2.3.0 版开始通过 L.mapbox.styleLayer
支持样式 url:
L.mapbox.accessToken = YOUR_ACCESS_TOKEN;
var map = L.mapbox.map('map').setView([38.97416, -95.23252], 15);
// Use styleLayer to add a Mapbox style created in Mapbox Studio
L.mapbox.styleLayer('mapbox://styles/mapbox/emerald-v8').addTo(map);
参见:https://www.mapbox.com/mapbox.js/example/v1.0.0/stylelayer/
关于javascript - 是否可以将传单版本 1 与自定义 mapbox 样式一起使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35590579/