I would like display in popup a various set of attributes depends of selected layer. I have:
var selectControl = new OpenLayers.Control.SelectFeature(
[layer1, layer2],
{
clickout: true, toggle: false,
multiple: false, hover: false,
toggleKey: "ctrlKey", // ctrl key removes from selection
multipleKey: "shiftKey" // shift key adds to selection
}
);
and:
function onFeatureSelect(event) {
var feature = event.feature;
var selectedFeature = feature;
var text = ""
if(feature.cluster) {
for(var i=0; i<feature.cluster.length; i++) {
//and here should be something about which layer is selected eg.
//if ( selectControl == layer1 )
//then {first set of attributes} else {second set of attributes}
//... How to do htis?
//This idea doesn't work, I received undefined value of attributes
text += [i+1]+". "+feature.cluster[i].attributes.gis_id +"<br>";
}
else {
text = feature.attributes.gis_id;
}
var popup = new OpenLayers.Popup.FramedCloud("chicken",
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(100,100),
text,
null, true,
onPopupClose,
function() { controls['selectControl'].unselectAll(); }//
);
feature.popup = popup;
feature.popup.closeOnMove = true;//
map.addPopup(popup);
};