2016-12-26 56 views
0

我已創建使用下面的OpenLayers一個線串: -的OpenLayers,JavaScript的

$.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()。我試過使用removeFeatures(),destroy(),removeLayer()方法來實現這個功能。但沒有任何工作。

請幫忙。

回答