Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3936566
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:57:48+00:00 2026-05-19T23:57:48+00:00

I have an OpenLayers/GeoExtJS map that I have a WMSGetFeatureInfo popup come up every

  • 0

I have an OpenLayers/GeoExtJS map that I have a WMSGetFeatureInfo popup come up every time a user clicks a point on the map. However, the popup is displaying results even for layers which are not visible at the resolution which is set at the time of the user’s click. The OpenLayers layer.calculateInRange() tells me quite nicely which layers are currently in range or not, but I do not know how to eliminate them from the getfeatureinfo request…

Even trying the eventListener beforegetfeatureinfo did not work…

Any ideas would truly be wonderful 🙂

var layersToBeQueried = [layerA, layerB, layerC, layerD, layerE];

function removeLayersOutOfRange(layerArray) {
    for (var i = 0; i < layerArray.length; i++) {
        alert(layerArray[i].name);
        if (layerArray[i].calculateInRange() == false) {
            layerArray.splice(i, 1);
        }
    }
    return layerArray;
}
var info = new OpenLayers.Control.WMSGetFeatureInfo({
    url: layerURL,
    layerUrls: [layerURL],
    title: 'Identify features by clicking',
    queryVisible: true,
    eventListeners: {
        beforegetfeatureinfo: function (event) {
            this.layers = removeLayersOutOfRange(layersToBeQueried);
        },
        getfeatureinfo: function (event) {

            if (event.text.length <= 687) { } else {

                popup = new GeoExt.Popup({
                    title: "Popup",
                    location: event.xy,
                    autoScroll: true,
                    height: $('#myViewPort').height() - 250,
                    maximizable: true,
                    collapsible: true,
                    map: mapPanel.map,
                    anchored: true,
                    html: '<div id="popupWrap"></div>',
                    listeners: {
                        close: function () {
                            // closing a popup destroys it, but our reference is truthy
                            popup = null;
                        }
                    }
                });

                popup.show();

            }//end if
        }//end getfeatureinfo
    }//end eventListeners
});//end OpenLayers.Control.WMSGetFeatureInfo

mapPanel.map.addControl(info);
info.activate();

Thanks,

elshae

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:57:49+00:00Added an answer on May 19, 2026 at 11:57 pm

    Not a solution to your original problem, but I think you should rethink the removeLayersOutOfRange function. Using splice on you array will change it while in the loop, thus changing the indices as well. This means you won’t loop through all layers correctly.

    I would suggest you create a new array and push the layers that are in range into that array, passing that on instead of editing the input array.

    Something like this (untested):

    function removeLayersOutOfRange(layerArray){
        var retArray = new Array();
        for(var i = 0; i < layerArray.length; i++) {
            //alert(layerArray[i].name);
            if(layerArray[i].calculateInRange() == false){
                retArray.push(layerArray[i]);
            }
        }
        return retArray;
    }
    

    Looking at your original problem now. Maybe the layer logic could be performed when the search is completed? In the getFeatureInfo method, asking the layer logic which layers are visible, and then compile a message only using info from those layers? Messing with the query layers could perhaps be the culprit here. Not having experience in that, only guessing…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an OpenLayers map with a marker and a popup that's supposed to
I have a pretty well integrated OpenLayers map that I want to add photos
I have a map in OpenLayers that has a number of layers with Markers.
I have a heat map application on OpenLayers where user enters two date and
have written this little class, which generates a UUID every time an object of
I would have an openlayers vector layer with features scattered all over the map.
TLDR : I have an Openlayers map with a layer called 'track' I want
I have added a large image to the openlayers map I have built. The
In Javascript. I have a map of the world that is 1024 x 1024px
I have a pretty basic setup of a map with openlayers, and just 3

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.