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.

Comments

strk’s picture

StatusFileSize
new3.25 KB

So, 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.

tmcw’s picture

Okay, cool, a few things:

  • Shouldn't this be assigned to a particular layer? It would make sense if there was enough code in the PHP side that this could be assigned to WMS layers only.
  • The current description
    Adds info boxes on maps clicks.

    doesn't describe this very well and would definitely lead to users enabling this when they actually want Tooltip or Popups.

  • Why isn't this using the code in OpenLayers.Control.WMSGetFeatureInfo? That seems to require much, much less custom work.
strk’s picture

Shouldn't this be assigned to a particular layer? It would make sense if there was enough code in the PHP side that this could be assigned to WMS layers only.

I 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.

Why isn't this using the code in OpenLayers.Control.WMSGetFeatureInfo

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.

tmcw’s picture

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 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.

strk’s picture

This doesn't keep support for normal OpenLayers.Layer.Vector layers.

It does. Did you try it ?

This patch also uses a different bit of code for theming popups

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).

what this does isn't adding a popup to a map, it's running a query against a server and displaying the results.

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.

strk’s picture

StatusFileSize
new3.44 KB

New 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.

strk’s picture

StatusFileSize
new3.63 KB

Timeout implemented

strk’s picture

StatusFileSize
new3.99 KB

General 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.

strk’s picture

StatusFileSize
new14.73 KB

And 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 ..

tmcw’s picture

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.

The 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.

strk’s picture

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.

Maybe 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.

tmcw’s picture

Hence 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).

strk’s picture

Ok, 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

strk’s picture

FYI, 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.

tmcw’s picture

Status: Active » Postponed (maintainer needs more info)

Unless there's demand for a simple WMSGetFeatureInfo-based behavior, there aren't any actions remaining on this ticket, I'd assume?

strk’s picture

Title: Add WMS GetFeatureInfo support » Add WMSGetFeatureInfo behavior

Yeah, I guess so.

batje’s picture

Issue tags: +wms
StatusFileSize
new13.81 KB

I did a similar effort, and created #951912: WMS Getfeatureinfo module (and i can not delete the attachment here, it seems)

zzolo’s picture

@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?

batje’s picture

I 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)

strk’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)
batje’s picture

Component: Behaviors » OL API

I 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