带有静态图像的地图从Geoserver添加图层

时间:2019-02-07 21:03:47

标签: openlayers geoserver

使用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更改为ImageStaticImageStatic不支持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); 

0 个答案:

没有答案