我能够毫无问题地使用mapbox标准和卫星图块,并且可以在图层之间来回切换。但是当我尝试使用室外图层时,我收到401错误。这是我设置图层的地方:
var mapLayer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.streets',
accessToken: '<mytoken>'
}),
satLayer = L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.satellite',
accessToken: '<mytoken>'
}),
terrainLayer = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/outdoors-v9/tiles/256/{z}/{x}/{y}??access_token={accessToken}', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
maxZoom: 18,
id: 'mapbox.outdoors',
style: 'mapbox://styles/p-craig-peddie/<styletoken>',
accessToken: '<mytoken>'
});
var baseMaps = {
"Default": mapLayer,
"Terrain": terrainLayer,
"Satellite": satLayer
};
var map = L.map('leafletMap', {
center: [33.559768, -117.728416],
zoom: 8,
layers: [mapLayer, polyLayer, gridLayer]
});
知道我做错了吗?
答案 0 :(得分:0)
双重问号&#39; ??&#39;在URL中是罪魁祸首。咄。