Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

Thank you, Bogdan

share|improve this question
add comment

2 Answers

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]);
   };
};

i hope it helps you...

share|improve this answer
    
Thank you Aragon! I don't need to remove popups, but links on the first popup which open other popups. You can see how it looks here: jorix.github.com/OL-FeaturePopups/examples/feature-popups.html Just clicl on a big yellow circle. –  Bogdan Nov 19 '12 at 23:02
add comment

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 is a bit more simple, not much. It seems this way acceptable? If so, I will prepare a tested code for tooltips.

WARNING: To use this trick you should update the control, today it has made ​​a small adjustment.

share|improve this answer
    
It works but only for popups. It would be nice to have a solution for tooltips also. I just add this condition on your code: if (jQuery.inArray(sel.features[ii].attributes["name"], namesInPopup) == -1) { // ******** FILTER DUPLICATES HERE ****************** and the initialisation of namesInPopup array some lines before: var html = [], htmlAux = [], namesInPopup = []; –  Bogdan Nov 22 '12 at 0:20
    
Jorix updated the control and set an extended example here: jorix.github.com/OL-FeaturePopups/examples/… Now the list of features from the cluster tooltip and popup is very simple to manage. This solved my problem. Thank you Jorix! –  Bogdan Nov 23 '12 at 0:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.