Hi guys,
We have a node type with about 60 fields of various types on it. One of these is the PostGIS geospatial data field.
In a spatial context, we want to have a limited subset of fields available to the user via WFS and via the pop-up info box implemented by Openlayers.
In the Geoserver UI, we can define a new layer, and choose the spatial data field as the source.
Now there are two points I'm confused about:
1. In the Layer definition, under Layer Specifics, we get an automated SQL query that joins all 60 fields (seems like a lot of overhead?).
2. I don't see where to intervene in the UI workflow and tell Geoserver which fields I want to use for the Popup info box fields (title and description).
Any clues please?
Thanks,
JB

Comments

friedjoff’s picture

Hi JB!

1.) Feel free to adapt the automatically generated SQL query to suite your needs. You can always remove fields you don't need.

2.) Just name the column which should appear in the popup title "name" and the column which should appear in the popup description "description". You can also theme the OpenLayers popup directly: https://drupal.org/node/844960

Does this answer your question?

boabjohn’s picture

G'Day Friedjoff,
As always, thank you for the time to field queries and support people who are just clinging on to the steep part of the learning curve...
My experience so far has been with OpenLayers + GeoPHP + GeoField all going thorugh Views as a query and presentation builder.
I realise the benefits of PostGIS and doing the complex spatial operations in the db rather than in GeoPHP, and I also realise the complexities of connecting to Views (I read your Roadmap threads and see that it's been pretty quiet for nearly 6 months now?).
So, with all that context, I'm still stumped as to how to achieve a "simple" usecase. Imagine we are on an index page where many of these nodes are displayed on a map. We want the user to click a point, get an info box with useful content, and be able to link from this box to the associated node record.
Recapping:
1. On a node type with a spatial data field and a bunch of pre-existing fields (and field names)
2. We want to create an info box that shows
(a) a value for "title"
(b) a link from "title" to the node
(c) a value for "description"
3. Now let's go to the documentation:

To do so open Structure » GeoServer and edit the layer in question. Modify the SQL query so that a column name provides the popup's title and a column description its main content.

This is the most specific piece of instruction I have found. However, for someone like me, this is impossible to gain traction on...
(a) My "title" field is not called "title"...it is called "name". How do I (safely) alter the SQL query so that GeoServer can understand "name" = "title" ?
(b) How can I add the html code and token support so that when the query is resolved it will render a link in the info box?
(c) I have no field called "description" and would actually like to concatenate several fields into one text block (or table). This is surely advanced styling, but what would be the options? Are you planning to support something like CartoDB's infowindows approach?
Thanks again for your support.
JB

boabjohn’s picture

Hmmm...have I slipped off the edge of the supportable universe?

friedjoff’s picture

Hi boabjohn,

the most flexible way to theme your OpenLayers popups is documented here: https://drupal.org/node/844960

You will need to add some custom JavaScript in your own theme or module (see https://drupal.org/node/304255 for details).

Just copy the Drupal.theme.prototype.openlayersPopup function from http://drupalcode.org/project/openlayers.git/blob/refs/heads/7.x-2.x:/pl... to your own JavaScript file and adapt the function to your own needs. All columns from the SQL definiton of the GeoServer layer will be available as attributes.

Regards,
friedjoff