使用openlayers 4.6.5。我可以成功添加静态图像。我想在此之上添加从geoserver获得的另一层。 openlayers生成的请求称crs为jpg。返回的错误是:
Error occurred decoding the espg code jpg No authority was defined for code "JPG". Did you forget "AUTHORITY:NUMBER"?
我尝试将catLayer更改为ImageStatic
。 ImageStatic
不支持getSource()
,需要更改源参数。
所以我在如何添加catLayer上遇到了麻烦。
const pixelProjection = new ol.proj.Projection({
code: 'pixel',
units: 'pixels',
extent: [0, 0, 800, 600]
})
const yard = new ol.layer.Image({
source: new ol.source.ImageStatic({
url: this.mapInfo.src,
projection: projection,
imageExtent: extent
})
});
this.map = new ol.Map({
layers: [yard],
target: 'map-jpg',
view: new ol.View({
projection: projection,
center: ol.extent.getCenter(extent),
zoom: this.info.zoom,
minZoom: this.info.minZoom,
maxZoom: this.info.maxZoom
})
});
this.catLayer = new ol.layer.Image({
name: 'catLayer',
visible: true,
source: new ol.source.ImageWMS({
url: this.base,
params: { layers: 'cats' },
serverType: 'geoserver',
crossOrigin: null
})
});
this.map.addLayer(this.historicalOverlay);