我有一个带坐标的xml文件,我想在Openlayers Map上绘制一行这些点。我已经有一个Openlayers.Layer.Vector,我正在创建一个如下功能:
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]);
这是预期的,我在地图上看到一条线。现在的问题是,我从.xml获得的点数是由另一个程序动态更改的,我想在我的地图上实时绘制这些更改。我已经有一种定期更新地图的方法,但是如何将要素/几何更新为新点?
答案 0 :(得分:0)
尝试aLayer.drawFeature(yourChangedFeature);