0

No one question from stackExchange with similliar title works for me. Cause I face another situation. I added WMS layer, and chrome's debuger throws this Group.js?d2e6:207 Uncaught TypeError: layer.getLayerStatesArray is not a function. So map havn't displayed. Code is simple:



import { Map, View } from 'ol';
import { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer.js';
import OSM from 'ol/source/OSM';
import TileWMS from 'ol/source/TileWMS.js';
import ImageWMS from 'ol/source/ImageWMS.js';
import ImageLayer  from 'ol/Image.js';
import VectorSource from 'ol/source/Vector.js';
import { bbox as bboxStrategy } from 'ol/loadingstrategy.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import { Circle as CircleStyle, Fill, Stroke, Style } from 'ol/style.js';

var imageGeoServer = new ImageLayer({
    source: new ImageWMS({

        url: 'http://mydomen.local:8080/geoserver/test_osm/wms',
        params: {
        'LAYERS': 'wspace:layer_set',
        'TILED' : true,
        },
        projection: 'EPSG:3857',
        serverType: 'geoserver'

    }),
    zIndex: 0
})

var vectorSource = new VectorSource({
    format: new GeoJSON(), 
    url: function (extent) { 
        return 'http://localhost:/collections/1/items/.....'+extent.join(',');

    },
    strategy: bboxStrategy
});

var vector = new VectorLayer({
    source: vectorSource,

    style: styleFunction,
    zIndex: 1
});

var map = new Map({
    layers: [vector,imageGeoServer],
    target: document.getElementById('map'),
    view: new View({
        center: [4237635.289265558, 6645635.289265558],
        maxZoom: 19,
        zoom: 6
    })
});

What is wrong?

  • 1
    Source ImageWMS is intended for single images (see example openlayers.org/en/latest/examples/wms-image.html), but you are requesting tiled images from WMS server. – TomazicM Aug 7 at 8:43
  • @TomazicM thanks for this. But what is funny, in another app, ImageWMS source works great for layerset from geoserve)) So ImageLayer isn't good choice for tile from geoserver too? – Tyomik_mnemonic Aug 7 at 8:47
  • Your import of ImageLayer is wrong. Use import { Image as ImageLayer, Tile as TileLayer, Vector as VectorLayer } from 'ol/layer.js'; – Mike Aug 7 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.