[英]OpenLayers 5.3 How I can set a square BBOX in a ol.layer.Image?
This is the code : It works but returns with a BBOX definited like a rectangle 这是代码:它可以工作,但返回的BBOX像矩形一样确定
function createLayer () {
var e = 20037508.34;
var tileGrid = new ol.tilegrid.TileGrid({
origin: [-e, -e],
extent: [-e, -e, e, e],
resolutions: [168e3, 84e3, 42e3, 21e3, 14e3, 5600, 2800, 1400, 560, 280, 140, 70, 28, 14, 7, 5.6, 4.2, 2.8, 1.4, .56, .42, .28],
});
var layers = [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'hidelink',
params: {
'LAYERS': 'pianificazione:v_ps_timewms_vinc_archeologico_vigente',
'SRS':'EPSG:900913',
'FORMAT': 'image/png; mode=8bit',
'VERSION': '1.1.0',
'WIDTH': '256',
'HEIGHT': '256'
},
tileGrid: tileGrid
})
})
];
return layers;
}
I need that this rest call return with a image in a square BBOX . 我需要这个rest调用返回一个带有正方形BBOX的图像。 How I can do?
我该怎么办?
ImageWMS will set the BBOX to fill the viewport, TileWMS sets the BBOX to fill a tile, in both cases any width WIDTH and HEIGHT you specify will be overridden. 在两种情况下,ImageWMS都会将BBOX设置为填充视口,TileWMS会将BBOX设置为填充图块,在两种情况下,您指定的宽度WIDTH和HEIGHT都会被覆盖。 Since you have set up a tile grid I suspect you wanted tiles
由于您已经设置了瓷砖网格,我怀疑您想要瓷砖
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'hidelink',
params: {
'LAYERS': 'pianificazione:v_ps_timewms_vinc_archeologico_vigente',
'SRS':'EPSG:900913',
'FORMAT': 'image/png; mode=8bit',
'VERSION': '1.1.0'
},
tileGrid: tileGrid
})
What's not working? 什么不起作用? With that layer parameter I presume you are using one of the Italian municipal services.
使用该图层参数,我想您正在使用意大利市政服务之一。 I found this one for Firenze and this code is returning 256 x 256 tiles for me
我为Firenze找到了这个,此代码为我返回了256 x 256个图块
<!DOCTYPE html>
<html>
<head>
<title>WMS Test</title>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/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://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
</head>
<body>
<div id="map" class="map"></div>
<script>
function createLayer () {
var e = 20037508.34;
var tileGrid = new ol.tilegrid.TileGrid({
origin: [-e, -e],
extent: [-e, -e, e, e],
resolutions: [168e3, 84e3, 42e3, 21e3, 14e3, 5600, 2800, 1400, 560, 280, 140, 70, 28, 14, 7, 5.6, 4.2, 2.8, 1.4, .56, .42, .28],
});
var layers = [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://tms.comune.fi.it/geowebcache/service/wms',
params: {
'LAYERS': 'pianificazione:v_ps_timewms_vinc_archeologico_vigente',
'SRS':'EPSG:900913',
'FORMAT': 'image/png; mode=8bit',
'VERSION': '1.1.0'
},
tileGrid: tileGrid
})
})
];
return layers;
}
var map = new ol.Map({
layers: createLayer (),
target: "map",
view: new ol.View({
center: ol.proj.fromLonLat([11.23, 43.77]),
zoom: 12
})
});
</script>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.