TTT
TTT

Reputation: 1885

OpenLayers 3: "Unable to get property 'leaf' of undefined or null reference."

Using Open layers 3.7.0. I have layer with features. I remove one, build a new similar one, add the new one and I get error message "Unable to get property 'leaf' of undefined or null reference."

I have searched for what could cause that but search don't give any result.

Some more from the same error (I used v3.8.2 here but got exactly the same: at rbush.prototype._chooseSubtree (http://openlayers.org/en/v3.8.2/build/ol-debug.js:70778:13) at rbush.prototype._insert (http://openlayers.org/en/v3.8.2/build/ol-debug.js:70815:9)

at rbush.prototype.insert (http://openlayers.org/en/v3.8.2/build/ol-debug.js:70623:19) at ol.structs.RBush.prototype.insert (http://openlayers.org/en/v3.8.2/build/ol-debug.js:71178:3) at ol.source.Vector.prototype.addFeatureInternal (http://openlayers.org/en/v3.8.2/build/ol-debug.js:71589:7) at ol.source.Vector.prototype.addFeature (http://openlayers.org/en/v3.8.2/build/ol-debug.js:71566:3)

Progress

Where we build the feature we have a projection.

var lineString = new ol.geom.LineString(coordinates);
lineString.transform("EPSG:4326", "EPSG:3857");
var feature = new ol.Feature(lineString);
(...)

If we comment/remove

//lineString.transform("EPSG:4326", "EPSG:3857");

Then there is no bug. By the way that's an hint, not a solution as the features are then not located where they should be.

Solution found

I do not think that this is a perfect soluton but I solved the problem regarding or application by saving the LineStrings in memory instead of re-creating it. Then I still recreate the Feature from existing LineString.

Upvotes: 0

Views: 880

Answers (1)

mapgiordani
mapgiordani

Reputation: 65

I got the same error on console and I solved this testing if the features had a valid geometry(coordinates), so I discard the inclusion of the invalid features on the layer source.

Upvotes: 0

Related Questions