如何解决如何在openlayer 6.4.3中将tilegrid添加到平铺层
我添加了2层OSM和我的区域层(使用MapProxy和Mapnik生成的图块)。我的代码是:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://openlayers.org/en/v6.4.3/css/ol.css" type="text/css">
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://openlayers.org/en/v6.4.3/build/ol.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.6.1/proj4.js"></script>
<style>
html,body,.map {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
proj4.defs("EPSG:32643","+proj=utm +zone=43 +datum=WGS84 +units=m +no_defs");
ol.proj.proj4.register(proj4);
var map = new ol.Map({
target: 'map',layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),new ol.layer.Tile({
source: new ol.source.XYZ({
url: "http://127.0.0.1:8080/tms/1.0.0/district/distgrid" + "/{z}/{x}/{-y}.png",tileGrid: new ol.tilegrid.TileGrid({
extent: [291627,904686,958569,1426831],tileSize: [512,256],}),projection: "EPSG:32643",})
],view: new ol.View({
projection: "EPSG:32643",units:"m",zoom:0,maxZoom:12,minZoom:0
})
});
map.getView().setZoom(map.getView().getZoom() - 6);
</script>
</body>
</html>
当我添加 tileGrid时出现问题:new ol.tilegrid.TileGrid({... 我遇到错误 Uncaught TypeError:e undefined 。如果我删除了。实际上,我不需要OSM层,只是添加了参考,图片中显示的 5 是一个群集已添加到地图中,但上面的代码中未包含。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。