Openlayer WMS GetFeatureInfo response null

323 views Asked by At

I'm facing a problem with GetFeatureInfo from WMS layer (published by my own via geoserver). After singleClick I have response no value. The WMS layers is EPSG 3857 like map view as well. I have been trying with example from openlayer and everything works fine. I do not have any idea what is wrong. Please find below my main.js file

import './style.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import TileWMS from 'ol/source/TileWMS';


const wmsSource1 = new TileWMS({
  url: 'https://portal.solarmap.pl/geoserver/ows?service=wms',
  params: {'LAYERS': 'solarmap-swidnica:VEG_IRR_FIELD_4'},
  serverType: 'geoserver',
  // projection: 'EPSG:3857',
  crossOrigin: 'anonymous',
});

const basemap = new TileLayer({
  source: new OSM(),
});


const wmsLayer1 = new TileLayer({
  source: wmsSource1,
});

const view = new View({
  center: [0, 0],
  zoom: 1,
});

const map = new Map({
  layers: [basemap, wmsLayer1],
  target: 'map',
  view: new View({
    projection: 'EPSG:3857',
    center: [1833048, 6593400],
    zoom: 18,
}),
})

map.on('singleclick', function (evt) {
  // document.getElementById('info').innerHTML = '';
  const viewResolution = /** @type {number} */ (view.getResolution());
  const url = wmsSource1.getFeatureInfoUrl(
    evt.coordinate,
    viewResolution,
    'EPSG:3857',
    {'INFO_FORMAT': 'text/html'}
  );
  console.log(url);
  if (url) {
    fetch(url)
      .then((response) => response.text())
      .then((html) => {
        document.getElementById('info').innerHTML = html;
      });
  }
});

I have chekced the WMS layer by goeserver - preview. There is a possibility to view feature value, so the problem is not in WMS I hope. Link to the WMS preview: preview WMS

0

There are 0 answers