epyks23,
by default, GetFeatureInfo will show info for all layers. GeoServer does not know which layers are visible in your browser, so you have to pass it the names of visible layers in the param argument of testSource.getGetFeatureInfoUrl().
On way to do this is in "map.on('singleclick', function(evt) {":
- loop over the layers list
- call get("visible") on each layer to get the visibility status set by the layer switcher
- for each visible layer, append its name to a list of visible layer names
- join the list of visible layer names into a single string containing comma-separated layer names
- pass the string of comma-separated visible layer names as an additional parameter QUERY_LAYERS in the map in the last argument of testSource.getGetFeatureInfoUrl
Kind regards,
Ben.
On 16/01/16 18:07, epyks23 wrote:
I have created a map using layers I added in GeoServer.
I created GetFeatureInfoUrl function to get the attribute table when
clicking on layer.
But when I click on the map, all the info boxes of all the layers show up.
Even if a layer (which is on top of another layer) is turned off, its
attribute information comes up.
info.PNG <http://osgeo-org.1560.x6.nabble.com/file/n5245626/info.PNG>
How can I make it so that only one info box shows up at a time? (So if two
layers are on top of each other and user click on the map, the attribute
information of the layer which is on top of the other will show up.)
So in this case, if I click on the UK, the bedrock layer info should show
up. If I turn off the bedrock layer, and click on the Great Britain layer,
the attribute information of Great Britain should show up.
layers.png <http://osgeo-org.1560.x6.nabble.com/file/n5245626/layers.png>
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Multiple-info-boxes-showing-up-when-I-click-on-map-tp5245626.html
Sent from the GeoServer - User mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/>
New Zealand