空白地图图块-错误410消失了(Mapbox& Leaflet JS) [英] Blank map tiles - Error 410 gone (Mapbox & Leaflet JS)

查看:271
本文介绍了空白地图图块-错误410消失了(Mapbox& Leaflet JS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Leaflet JS和MapBox创建地图.我的浏览器显示如下:

I am using Leaflet JS and MapBox to create a map. My browser displays as below:

地图完全不显示,我的地图图块为空白.我在开发工具控制台中遇到的错误是:

The map does not show at all, my map tile is blank. The errors that I get in the dev tools console is:

GET https://api.tiles.mapbox.com/v4/mapbox.streets/9/123/183.png?access_token=pk.eyJ1IjoibXl2ZXJkaWN0IiwiYSI6ImNrZmoyYmpuNDB1eHYycG16bms0aHN2ZWwifQ.w0DRp5yDUHxa2RJa0aDRlQ 410 (Gone)
Image (async)       
createTile  @   TileLayer.js:158
_addTile    @   GridLayer.js:812
_update     @   GridLayer.js:709
_setView    @   GridLayer.js:570
_resetView  @   GridLayer.js:526
 onAdd      @   GridLayer.js:162
_layerAdd   @   Layer.js:114
whenReady   @   Map.js:1465
addLayer    @   Layer.js:176
addTo       @   Layer.js:52
(anonymous) @   maps.js:16

上面的maps.js:16在下面的maps.js代码段中引用了最后一行.addTo(map):

The maps.js:16 above references the last line .addTo(map) in the maps.js code snippet below:

let coordinates = [ 44.96, -93.2 ] 
let zoomLevel = 9
let map = L.map("college-map").setView(coordinates, zoomLevel)

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery &copy; <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox.streets',
accessToken: 'your-access-token'
}).addTo(map)

如何解决此错误并成功显示地图?

How do I fix this error and display the map successfully?

推荐答案

"410 Gone客户端错误响应代码表示对以下内容的访问: 目标资源在原始服务器上不再可用,并且 这种情况很可能是永久性的."

"410 Gone client error response code indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent."

如果您打开自己的链接

If you open your link https://api.tiles.mapbox.com/v4/mapbox.streets/9/123/183.png?access_token=pk.eyJ1IjoibXl2ZXJkaWN0IiwiYSI6ImNrZmoyYmpuNDB1eHYycG16bms0aHN2ZWwifQ.w0DRp5yDUHxa2RJa0aDRlQ in the browser, you will get this:

{消息":"不再支持经典样式;看 https://blog.mapbox.com/deprecating-studio-classic-styles-d8892ac38cb4 有关更多信息"}}

{"message":"Classic styles are no longer supported; see https://blog.mapbox.com/deprecating-studio-classic-styles-d8892ac38cb4 for more information"}

另请参阅:

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆