I am working on modify function for an Openlayers project. I define a vector layer for modify objects. (line, polygon etc.) But then I take an error like below while adding vector layer to map object. Why am i getting this?


Uncaught TypeError: layer.getLayerStatesArray is not a function
at ol-debug.js:17395
at ol.Collection.forEach (ol-debug.js:8289)
at ol.layer.Group.getLayerStatesArray (ol-debug.js:17394)
at ol.Map.ol.PluggableMap.renderFrame_ (ol-debug.js:18670)
at ol.Map.<anonymous> (ol-debug.js:17624)

Source Code (core)

        init: function (Map) {
            var self = this;
            self.Map = Map;
            self.VectorSource = new ol.source.Vector({ wrapX: false });
            self.initialized = true;

Source Code (UI)

var geo = (new ol.format.GeoJSON()).readFeatures(e, { featureProjection: 'EPSG:3857' })[0];

Referenced example

1 Answer 1


You must give "ol.layer.Vector" object to addLayer method. For example:

var vectorLayer = new ol.layer.Vector({
      source: new ol.source.Vector()


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.