Search code examples
geometryopenlayerslayer

How to update a feature in an Openlayers.Layer?


i have an xml file with coordinates in it and i want to draw a line of those points on an Openlayers Map. I already have a Openlayers.Layer.Vector and i am creating a feature as follows:

var points = [];
for (var i = 0; i < coords.length; i++)
{
    point = new OpenLayers.Geometry.Point(aPointsArray[i].lon, aPointsArray[i].lat);
    points.push(point);
}
var geometry = new OpenLayers.Geometry.LineString(points);
var feature = new OpenLayers.Feature.Vector(geometry, null,
{
    strokeColor: aColor,
    strokeOpacity: 0.7,
    strokeWidth: 3
});
aLayer.addFeatures([feature]);

This works a expected and i am seeing a line on my map. The problem is now, that the points i get from the .xml are changed dynamically by another program and I want to draw those changes live on my map. I already have a method that updates the maps periodically but how do i update the feature/geometry to the new points ?


Solution

  • Try aLayer.drawFeature(yourChangedFeature);