TomTom 图块图层未包含在传单地图中



目前正在开发一个应用程序(地图(,我想在传单顶部使用汤姆汤姆瓷砖图层。由于Leaflet的文档,我想坚持使用Leaflet,而不是Tom Tom。我成功地使用 Tom Tom 方法设置了地图,但我无法使用传单库添加切片图层。

我看不出我做错了什么。有人可以帮忙吗?

根据传单教程,代码应如下所示:https://leafletjs.com/examples/quick-start/

汤姆汤姆磁贴地图 API URL 可以从以下位置生成: https://developer.tomtom.com/content/maps-api-explorer#/Vector/get_map__versionNumber__tile__layer___style___zoom___X___Y__pbf

'

// Creating a map instance with its center set to London with a zoom of 13
var mymap = L.map('map').setView([51.505, -0.09], 13);
// Accessing the tile layer from the TOMTOM site
L.tileLayer('https://api.tomtom.com/map/1/tile/basic/main/1/0/0.pbf?key=MY_API_KEY', {
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 © <a href="https://www.mapbox.com/">Mapbox</a>',
//id: 'mapbox.streets',
//accessToken: 'your.mapbox.access.token'
}).addTo(mymap);
<!DOCTYPE html>
<html>
<head>
<!-- Bootstrap css and scripts -->
<link rel="stylesheet" href="./00_Local_Bootstrapcssbootstrap.css">
<script src="./00_Local_Bootstrapjsbootstrap.js"></script>
<script src="./00_Local_Bootstrapjquery_3_4_1jquery_3_4_1.js"></script>
<!-- Leaflet css and scripts -->
<link rel="stylesheet" type="text/css" href="./Leafletleaflet.css" />
<script src="./Leafletleaflet.js"></script>
<style media="screen">
#map {
width: 50vw;
height: 50vh;
}
</style>
</head>
<body>
<!-- Map Import-->
<div class="container">
<p>Here is the map</p>
<div id='map'></div>
<!-- Mymap script -->
<script src="./welcome_page_leaflet.js"></script>
</div>
</body>
</html>

' 传单文档使用的是 Mapbox,这就是为什么它们引用相应的访问令牌和 ID 的原因。这就是为什么我把它注释掉了。

地图不加载瓷砖,我只看到地图应该在的空白屏幕。我错过了什么?

看起来您正在尝试通过用于栅格切片的传单切片图层显示矢量切片(带有 PBF 扩展名(。

TomTom 也提供光栅切片: https://developer.tomtom.com/maps-api/maps-api-documentation-raster/raster-tile

最新更新