Openlayers,javascript

Openlayers,javascript,javascript,openlayers,Javascript,Openlayers,我已使用以下openlayers创建了一个线条字符串:- $.each(coords, function(a){ console.log("entered coords:"+coords[a][0]+"//"+coords[a][1]); webcentre.lat = coords[a][0]; webcentre.lon = coords[a][1];

我已使用以下openlayers创建了一个线条字符串:-

$.each(coords, function(a){
                    console.log("entered coords:"+coords[a][0]+"//"+coords[a][1]);
                    webcentre.lat = coords[a][0];
                    webcentre.lon = coords[a][1];
                    mapref.panTo(webcentre);
                    var c = new openlayer.LonLat(coords[a][1], coords[a][0]),
                    e = new openlayer.Size(40, 70),
                    f = new openlayer.Pixel(-(e.w / 2), -e.h + e.h / 4),
                    g = new openlayer.Marker(c, new openlayer.Icon(l_wb1(coords[a][2]), e, f));
                    var startPt=new openlayer.Geometry.Point( coords[a][1], coords[a][0]);

                    if(a<(coords.length-1)){
                    //alert("a is less than coords length:::" +a);
                    endPt=new openlayer.Geometry.Point(coords[a+1][1],coords[a+1][0]);
                    }else {
                    //alert("a is greater than coords length");
                    endPt=new openlayer.Geometry.Point(coords[a][1],coords[a][0]);
                    }

                    console.log("startPt:"+startPt+"endPt:"+endPt);
                    line=new openlayer.Geometry.LineString([startPt, endPt]);
                    style={strokeColor : "red",
              fillColor : "black",
              pointRadius : 15,
              fillOpacity : 0.5,
              strokeWidth: 2,
              lineSymbol:"farrow",
                lineSymbolRadius:7,
                lineSymbolReverse:0,
                lineSymbolRepeat:0,
                lineSymbolOffset:0,
                lineSymbolStrokeWidth:2,
                lineSymbolStrokeColor:"green",
                lineSymbolFillColor:"green"};
                fea=new openlayer.Feature.Vector(line, {}, style);
                w = new openlayer.Layer.Vector(
                "Trace Layer",  {
                        styleMap: F
                }); 
                w.addFeatures([fea]);
                mapref.addLayer(w);
                    var dd1=[];
                    dd1.push(coords[a][1]);
                    dd1.push(coords[a][0]);
                    dd.push(dd1);
                    return s.addMarker(g), g


                });
我已尝试使用removeFeatures()、destroy()、removeLayer()。但什么都不管用


请提供帮助。

使用以下代码从矢量w中删除直线矢量fea:

w.removeFeatures(fea);

w.removeFeatures(fea);