I am creating a layer groups with:

      var vectorSource = new ol.source.Vector({
        features: (new ol.format.GeoJSON()).readFeatures(geoJson, {dataProjection: 'EPSG:4326', featureProjection: 'EPSG:3857'}),

      var vectorLayer = new ol.layer.Vector({
        source: vectorSource,
        style: observationStyle

      vectorLayer.set('name', observationGeoJson.features[i].properties.report_id);



      var newLayerGroup = new ol.layer.Group({
        layers: layerGroup,
        style: style

The GeoJson data source is then modified (the position of a point is changed). What is the best way to update the layer group? I have tried map.updateSize();, removing and adding the layer, .getSource().change() and .getSource().clear() + getSource().addFeatures(newFeatures) But the map is always rendering both the old geometry and the new geometry.

  • I resolved this with a super hack that will remove the first layer group when a second layer group is present. pastebin.com/iZVRV29n There must be a better way... – Bwyss Mar 11 '16 at 19:57
  • 1
    You could post the solution you found yourself as an answer. This will bounce up the question and can be upvoted. – underdark Oct 21 '16 at 18:03

the problem may be caused by the reference system or data projection. verify your geoJson file, if it has the same reference system or data projection than your openlayers code

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.