0

I have a feature created from Well Known Text as following:

var feature = format.readFeature(wkt , {
    dataProjection: 'EPSG:25830',
    featureProjection: 'EPSG:25830'
});

When I add it to a layer and try to center in the map like this:

this.vectorSource.addFeatures(feature);
this.map.getView().fit(feature.values_.geometry.extent_, {duration: 2500}); 

I get an AssertionError. When analyzing the feature I find the extent is set to infinity:

extent_: (4) [Infinity, Infinity, -Infinity, -Infinity]

How can I calculate the feature extent? How can I zoom and center the created feature on the map?

2

The solution was pretty simple:

Just replacing

feature.values_.geometry.extent_

with

feature.getGeometry().getExtent()

That worked fine.

Your Answer

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

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