I am new to OpenLayers and I wanted to add a modify feature function in my application, for this I need to know the feature type of the layer (i.e. point, polygon or line). Because as per the feature type I have to give permission to the user to draw a line, point or polygon.
So is there a way that I can get the layer feature type?
Best Answer
As suggested in comments
Layers
, to be more precise,Sources
don't restrict to be of one geometry type. If you want that you can extendol.source.Vector
to only allow one geometry type. Let's say we only want to includeol.geom.Point
's inol.source.Vector
:Now, you could do :
See a fiddle in action : https://jsfiddle.net/cxykqvwf/