我使用gdal对图像栅格进行了地理配准并使用EPSG创建了一个新的geotiff:3857。 现在我想在我的网站上显示它,我有两个问题,可能是因为我不太了解gdal,尤其是gdal2tiles的工作原理。我使用gdal2tiles.py -p mearcator z 1-8 source.tif Directory_tile和 我试图通过openlayers 3.15.1显示这个瓷砖....我怎么能这样做? 这是我的代码:
var mapMinZoom = 1;
var mapMaxZoom = 8;
var mapExtent = [32.93099653057996,5.51726084641600,47.57860125775348,19.97855309050547];
var valEnd='EPSG:900913';
var map = new ol.Map({
target: 'map2',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Tile({
extent: mapExtent,
source: new ol.source.XYZ({
url:'./assets/Directory_Tiles/{z}/{x}/{y}.png',
tilePixelRatio: 2,
type: 'png',
minZoom: mapMinZoom,
maxZoom: mapMaxZoom
})
})
],
view: new ol.View({
projection: valEnd,
center: [4720563.24719968624413,
614178.66799669514876],
zoom: 5
}),
maxResolution: 7520.000000,
rendering: 'canvas'
});
这是描述geotiff生成的切片的xml:
<?xml version="1.0" encoding="utf-8"?>
<TileMap version="1.0.0" tilemapservice="http://tms.osgeo.org/1.0.0">
<Title>source.tif</Title>
<Abstract></Abstract>
<SRS>EPSG:900913</SRS>
<BoundingBox minx="32.93099653057996" miny="5.51726084641600" maxx="47.57860125775348" maxy="19.97855309050547"/>
<Origin x="32.93099653057996" y="5.51726084641600"/>
<TileFormat width="256" height="256" mime-type="image/png" extension="png"/>
<TileSets profile="mercator">
<TileSet href="1" units-per-pixel="78271.51695000000473" order="1"/>
<TileSet href="2" units-per-pixel="39135.75847500000236" order="2"/>
<TileSet href="3" units-per-pixel="19567.87923750000118" order="3"/>
<TileSet href="4" units-per-pixel="9783.93961875000059" order="4"/>
<TileSet href="5" units-per-pixel="4891.96980937500030" order="5"/>
<TileSet href="6" units-per-pixel="2445.98490468750015" order="6"/>
<TileSet href="7" units-per-pixel="1222.99245234375007" order="7"/>
<TileSet href="8" units-per-pixel="611.49622617187504" order="8"/>
</TileSets>
</TileMap>
答案 0 :(得分:0)
url:'./ assets / Directory_Tiles / {z} / {x} / {-y} .png'
答案 1 :(得分:0)
您的url属性不是url。尝试使用托管它的服务器的FQDN。即:
url:'https://your.domain/assets/Directory_Tiles/{z}/{x}/{y}.png',