I am trying to append linear ring to multipolygon. When I try to do same for polygon it works.

case 'Polygon':

linearRing=new ol.geom.LinearRing(...);


case 'MultiPolygon':

linearRing=new ol.geom.LinearRing(...);

it's not throwing error, but still coordinates of created linearRing are not appended to selected feature..

  • The polygon with linearRing is created but it's not updated on map , I should remove existing polygon and append newly created, is there other and simpler way to do this ?
    – Goran
    Aug 19, 2019 at 13:23

1 Answer 1


A multipolygon is defined by an array of polygon coordinates, it isn't a collection of polygons so what is returned by getPolygon() or getPolygons() should be regarded as clones.

You could either push the linear ring coordinates into the appropriate polygon coordinates and build a new multipolygon

var feature = select.getFeatures().getArray()[0];
var coordinates = feature.getGeometry().getCoordinates();
feature.setGeometry(new ol.geom.MultiPolygon(coordinates));

or append the linear ring to the polygon then append each polygon clone to a new empty multipolygon

var feature = select.getFeatures().getArray()[0];
var polygons = feature.getGeometry().getPolygons();
var multiPolygon = new ol.geom.MultiPolygon([]);

The same applies to line strings returned by getLineString()/getLineStrings() from a multilinestring.

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.