I'd like to add support for GetFeatureInfo based popups.
Ideally, I see this as integrated in the existing 'popup' behavior, rather than a new behavior,
but not sure about that yet.
| Comment | File | Size | Author |
|---|---|---|---|
| #17 | wms.tar_.gz | 13.81 KB | batje |
| #9 | QueryBehaviorClean.patch | 14.73 KB | strk |
| #8 | query4_js_inc_only.tgz | 3.99 KB | strk |
| #7 | query3_js_inc_only.tgz | 3.63 KB | strk |
| #6 | query2_js_inc_only.tgz | 3.44 KB | strk |
Comments
Comment #1
strk commentedSo, I've some work done here.
It's still to cleanup but the idea is a behaviour which has pretty much the same look&feel than the 'popup' one, only adding
calls to WMS getFeatureInfo.
I attach the current version of the patch for anyone interested in it.
Might end up putting in a separate module for the time being.
Comment #2
tmcw commentedOkay, cool, a few things:
doesn't describe this very well and would definitely lead to users enabling this when they actually want Tooltip or Popups.
Comment #3
strk commentedI agree there's room for improvements there. I initially overlooked that as in our deploy we're letting users add their own layers, which are then not available in the preset edit form to select for enabling WMS query. But yes, as long as the list of layers on which featureInfo is enabled is in the map preset array any other module can add more layers there.
I'll try to come out with a better description, but the idea was really to make this an improvement of the Popup behavior.
What's different between a Popup and what this behaviour provides ? It is something that pops up, and contains informations
about features below the mouse at time of click. Just adds WMS support.
I don't remember if I tried that or not. Surely my code wants to query multiple layers, not a single one.
So I need a single click handler counting layers to query, perform the queries (asyncronously) and put
the different results togheter to show in a single popup. Not sure WMSGetFeatureInfo helps with that.
Comment #4
tmcw commentedI mean, they're hugely different. Popups won't do what this does, and this won't do what Popups do - this doesn't keep support for normal OpenLayers.Layer.Vector layers. This patch also uses a different bit of code for theming popups. So, yeah, the effect for the user is the same, but the jist of what this does isn't adding a popup to a map, it's running a query against a server and displaying the results.
Not that any of this is a bad thing, it's just somewhere where we really need to make sure that the terminology in the interface doesn't lead to user frustration. The vast majority of users are not using WMS layers and won't know that you can't query anything else with this patch.
A quick scan over the code in WMSGetFeatureInfo shows that it supports multiple layers and multiple requests.
Comment #5
strk commentedIt does. Did you try it ?
This is something I'd love to add, but couldn't from a _different_ behaviour (as the default theming
function wouldn't be available if the other 'popup' behavior isn't also enabled.
To help with that, default "feature information extractor" theming functions could be contained
in js/openlayers.js itself for peruse by different behaviors.
Note that by requesting XML output to WMS servers we might even reconstruct feature attributes
the same way we have them for vectors, so the theming functions could do a very similar thing
(for example: going over all attributes and build a table with name/value).
Running query against server is an implementation detail, the user visible effect is a popup comes out
with informations about the features shown on the map (both WMS and vectors).
I'm using this with view-driven vector layers, KML layers and WMS layers. All queried and all shown
in the popup :) The only difference you'll have is that this implementation doesn't stop on first feature
but finds all the ones close enough to the query point (hard-coded dependency of 10 pixel radius, to be exposed as a parameter). Give it a try to have a feel of it. NOTE: FAO WMS are often queriable.
Comment #6
strk commentedNew patch, only containing the .inc and .js files of the behavior, adds more options on the PHP side:
- List of layers to enable query on
- Query radius (only for vector layers as WMS doesn't seem to support that)
- Query timeout (for WMS layers, not implemented yet)
TODO:
1. Implement query timeout support
2. Cleanup/improve the content display part
As per 2. (content display part) I'd love to have a theming function taking an array of
layers each containing an array of feature attributes. Such a function would then have all
informations required to support vectors (clustered or not) and WMS layers in a transparent way.
Such function could be generic and used for all behaviors: query,popup,tooltip.
Comment #7
strk commentedTimeout implemented
Comment #8
strk commentedGeneral cleanup moving most code in a single class deriving from OpenLayers.Control.
There's still an IE bug related to order of Controls: when Navigation control is added _after_ this query control, double click
will be _also_ handled by query. Would probably need to check with online OL API and file a bug if persisting.
Comment #9
strk commentedAnd here's a CVS-clean patch before leaving for 2 weeks.
The patch includes also a .css but it's not really of any use right now.
I've removed some 'if (foo) continue' constructs as per tmcw request.
TODO:
- generalize the Control class more by removing presentation layer
- evaluate use of WMSGetFeatureInfo control for WMS layers
- fix IE problem with interaction between this behavior and Navigation one
- .. probably others I currently forgot ..
Comment #10
tmcw commentedThe WMSGetFeatureInfo built-in control provides the ability to drill down on multiple layers in a WMS layer.
Basically, I think that adding a wrapper around WMSGetFeatureInfo is a good idea. Implementing a new control that doesn't exist in OpenLayers proper is necessary for your use case but inappropriate for addition to the core of this module.
Comment #11
strk commentedMaybe if an abstract "query" behavior is inappropriate for core module the same can be told for the abstract "legend" behavior.
Both are not provided by the core OL library.
Comment #12
tmcw commentedHence why the legend behavior wasn't developed in OpenLayers core. But, while the OpenLayers library doesn't provide a layer control of any kind, it does provide a query implementation, which this doesn't use. Obviously, it's a grey area - it probably makes sense for the tooltips behavior to be replaced wholesale (since it's terrible), but this seems like it runs parallel to the built-in control but doesn't attempt to build on what the built-in control already provides (or allow the user to simply use the built-in control as provided).
Comment #13
strk commentedOk, for the time being I moved the code in a separate module (both query and legend behaviors).
Unfortunately they currently rely on some support from core, namely the legend management
functions and a sign of queriability for layers.
The non-core code is here: http://github.com/strk/dolpp
Comment #14
strk commentedFYI, the query and legend behaviors in dolpp module don't rely on any core modifications now, in case you want to give them a try.
Comment #15
tmcw commentedUnless there's demand for a simple WMSGetFeatureInfo-based behavior, there aren't any actions remaining on this ticket, I'd assume?
Comment #16
strk commentedYeah, I guess so.
Comment #17
batje commentedI did a similar effort, and created #951912: WMS Getfeatureinfo module (and i can not delete the attachment here, it seems)
Comment #18
zzolo commented@batje, your original message had much more description. Did something happen?
Does it make sense to take out the WMS functionality in this Drupal OL module and put it into a separate module, such as openlayers_wms? Or it could be more general as just wms?
Comment #19
batje commentedI moved the content to its own issue. #951912: WMS Getfeatureinfo module
As to naming. If we can decide that all WMS specific functionality, including the layers, goes into one module, then the most logical name for the module would be (A) wms (like wfs), or (B) openlayers_wms (in which case wfs should also be renamed to openlayers_wfs)
If the wms layers will stay in the openlayers module, then this module should be called something like (C) openlayers_wms_getfeatureinfo.
My personal preference is (B)
Comment #20
strk commentedComment #21
batje commentedI released a new version of my module as a sandbox. It works much better than the first attached effort, its 100% themable and it has a demo feature with it.
http://drupal.org/sandbox/batje/1244928