In OpenLayers ol.source.ImageVector
has been deprecated since v5.
Docs recommended to use an ol.layer.Vector
with renderMode: 'image'
instead.
But what if I want to get an another raster source at output? (Not a layer)
Is there any workaround?
Asked
Active
Viewed 127 times
0

Dmitriy Korobkov
- 867
- 1
- 11
- 25
1 Answers
1
The output from ol.source.Raster
is always a raster source. The input can be either a source or layer.
OpenLayers 4:
https://codepen.io/mike-000/pen/KKpgrmx
new ol.source.Raster({
sources: [
new ol.source.ImageVector({
source: new ol.source.Vector()
})
]
})
OpenLayers 5:
new ol.source.Raster({
sources: [
new ol.layer.Vector({
source: new ol.source.Vector()
}),
renderMode: 'image'
]
})
OpenLayers 6:
https://codepen.io/mike-000/pen/BaNLvyq
new ol.source.Raster({
sources: [
new ol.layer.VectorImage({
source: new ol.source.Vector()
})
]
})

Mike
- 16,042
- 2
- 14
- 30
-
But docs says, that sources of `ol.source.Raster` could be only objects that extend `ol.source.Source` object. `ol.layer.Vector` extends `ol.layer.Layer` object. – Dmitriy Korobkov Feb 20 '20 at 10:15
-
Sorry, this solution doesn't work. OpenLayers says `TypeError: Cannot read property 'ol_lm' of null` – Dmitriy Korobkov Feb 20 '20 at 10:25
-
Which version are you using? In versions 5 and 6 it can be subclasses of source or layer https://openlayers.org/en/v5.3.0/apidoc/module-ol_source_Raster-RasterSource.html https://openlayers.org/en/latest/apidoc/module-ol_source_Raster-RasterSource.html – Mike Feb 20 '20 at 17:36
-
I'm using v4.6.5 – Dmitriy Korobkov Feb 20 '20 at 17:43
-
You can use `ol.source.ImageVector` in version 4 https://codepen.io/mike-000/pen/KKpgrmx – Mike Feb 20 '20 at 18:25
-
It is deprecated – Dmitriy Korobkov Feb 20 '20 at 18:55
-
I posted a link to a working example using version 4.6.5. It wasn't removed until version 5. – Mike Feb 20 '20 at 19:00