I am using FeaturePopups control to show tooltips and popups for clusters. I have features connected (ends of road segments) with the same names.
Is it possible to remove them from tooltips and popups, so to have a list with unique names?
I am using FeaturePopups control to show tooltips and popups for clusters. I have features connected (ends of road segments) with the same names.
Is it possible to remove them from tooltips and popups, so to have a list with unique names?
It is necessary to rewrite the html list popup preparation using event "beforepopupdisplayed"
on option popupListOptions.eventListeners
as:
var fpControl = new OpenLayers.Control.FeaturePopups({
popupListOptions: {eventListeners: {
"beforepopupdisplayed": function(e){
var html = [],
htmlAux = [];
for (var i = 0, iLen = e.selection.length; i < iLen; i++) {
var sel = e.selection[i],
layerObj = sel.layerObj;
for (var ii = 0, iiLen = sel.features.length; ii < iiLen; ii++) {
// ******** FILTER DUPLUCATES HERE ******************
if (true) {
htmlAux.push(layerObj.renderTemplate(
layerObj.templates.item, sel.features[ii])
);
}
}
}
html.push(layerObj.renderTemplate(
layerObj.templates.list, {
layer: sel.layer,
count: sel.features.length,
html: htmlAux.join('\n')
}
));
e.html = html.join('\n');
}
}},
...
For tooltips it is a bit more simple, not much.
WARNING: To use this trick you should update the control, today it has made a small adjustment.
You can remove popups with some basic coding.
var allpps = map.popups;
for(var i=0; i < allpps.length; i++){
if(allpps[i].id.indexOf('blabla') > -1){ // You write what you want to put here.
map.removePopup(map.popups[i]);
};
};