[英]Openlayers, javascript
I have created a linestring using openlayers below:- 我已经使用以下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
});
Now when i remove the features on click of clear button, markers are removed but not the linestring. 现在,当我单击清除按钮时删除功能时,标记将被删除,但不会删除线串。
$.publish("clearHighlight", [l_maprefname]), s1 && (mapref.removeLayer(s1), s1 = void 0)
w && w.removeAllFeatures();
I have tried using removeFeatures(), destroy(), removeLayer(). 我尝试使用removeFeatures(),destroy(),removeLayer()。 But nothing works.
但是没有任何效果。
Please help. 请帮忙。
Use the following code to remove lines vector fea from Vector w: 使用以下代码从Vector w中删除行vector fea:
w.removeFeatures(fea);
http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html http://dev.openlayers.org/docs/files/OpenLayers/Layer/Vector-js.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.