WMTS在传单js中显示emty tile

问题描述 投票:0回答:1

我正在使用传单js和lantmateriet api来显示地图。但是地图在浏览器中显示空的白色瓷砖。与OSM等其他api一起显示的地图很好。我遇到了lantmateriet api的问题。这是我的代码。

var mapOptions = {
  center: [59.4022, 13.5115],
  zoom: 4
}

var map = new L.map('map', mapOptions);
L.tileLayer('https://api.lantmateriet.se/open/topowebb-ccby/v1/wmts/token/apikey/1.0.0/topowebb/default/3006/{z}/{y}/{x}.png', {
  attribution: ''
}).addTo(map);

var marker = L.marker([59.3293, 18.0686]).addTo(map);
var m2 = L.marker([59.9139, 10.7522]).addTo(map);
m2.bindPopup("Oslo").addTo(map);
marker.bindPopup('Stockholm').addTo(map);

var latlngs = [
  [59.9139, 10.7522],
  [59.4022, 13.5115],
  [59.3293, 18.0686]
];
var polyline = L.polyline(latlngs, {
  color: 'red'
});
polyline.addTo(map);

var circleCenter = [59.4022, 13.5115]; // Center of the circle
var circleOptions = {
  color: 'red',
  fillColor: '#f03',
  fillOpacity: 0.5,
}
// Creating a circle
var circle = L.circle(circleCenter, 10000, circleOptions);
circle.addTo(map); // Adding circle to the map
<!DOCTYPE html>
<html>

<head>
  <title>Leaflet sample</title>
  <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
  <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
</head>

<body>
  <div id="map" style="width: 900px; height: 580px"></div>
</body>

</html>

请帮我解决这个问题。提前致谢。

javascript api leaflet maps wms
1个回答
0
投票

看来你对lantmateriet的身份验证有问题(所有请求都获得了401返回代码),我没有看到任何用于身份验证的令牌。

我想你必须先检查一下。

401 unauthorized

© www.soinside.com 2019 - 2024. All rights reserved.