1

I have a map with polygons vector objects.

Superpositions can exist between the polygons. That is to say a bigger polygon is sometimes completely above a smaller one.
With Openlayers, is it possible to display two pop-ups instead of only one (the 1st pop-up being related to the polygon above, the 2nd being related to the polygon on the bottom) ? Or one pop-up containing the attributes of the two polygons ?

I looked for infos but didn't find a lot of stuff on that. There is that subject (Display multiple WFS layers with popup) but no answers.

Thank you very much for your help !

Julien
  • 699
  • 3
  • 14
  • 30

1 Answers1

5

For better user experience, I would recommend to show 1 popup containing the attributes of the two polygons.

Example: http://jsfiddle.net/HarolddP/2wfo5acf/3/

In the jsfiddle example there is a triangle polygon on top of the brazil polygon. Both have an attribute name. The innerHTML of the popup is filled by looping over the features (polygons) and adding the attributes to the innerHTML. Add some styling for better readability of the content, so that you know which text belongs to which polygon.

if (features.length > 0) {
    for (var i = 0, ii = features.length; i < ii; ++i) {
        popup.innerHTML = popup.innerHTML + ' ' + features[i].get('name');
    }
}
Leonardo Alves Machado
  • 2,747
  • 10
  • 38
  • 53
Harold
  • 68
  • 3