我有一个包含多个图层(A,B,C,D,E,F)的OpenLayers地图。 我需要能够选择不同图层上的项目并与它们进行交互。 目前我只能选择F层,而其他层阻止我在B层选择。
我创建了图层......
var Fields = new OpenLayers.Layer.Vector();
var Text = new OpenLayers.Layer.Vector();
将图层添加到我的地图
map.addLayers([Text, ZipCode, Legal, Fields, FieldLabels]);
调用我创建的高亮显示功能,因为功能正在添加到地图中...
function HighLighText(ID) {
//var mySelectStyle = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style["default"]);
//OpenLayers.Util.extend(mySelectStyle, { fillColor: "#f6b721", fillOpacity: 1 });
mySelectStyle[ID] = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style["default"]);
OpenLayers.Util.extend(mySelectStyle, { fontColor: "#F6FF00", fillOpacity: .6 });
mySelectStyle[ID].fontColor = "#F6FF00";
mySelectStyle[ID].fillOpacity = .6;
mySelectStyle[ID].label = String(ID);
var txtReport = function (e) { OpenLayers.Console.log(e.type, e.feature.id); };
highlightTextCtrl[ID] = new OpenLayers.Control.SelectFeature(Fields[ID], {
hover: true,
highlightOnly: true,
renderIntent: "temporary",
selectStyle: mySelectStyle[ID]
});
map.addControl(highlightTextCtrl[ID]);
highlightTextCtrl[ID].activate();
};
只要我隐藏上面的图层,上面的功能就很有效......如何在不隐藏图层的情况下完成这项工作?