I am serving numerous WMS layers through GeoServer, many of which have URLs leading to extended data for any particular feature embedded in their attribute table. The URL, if present, is always contained within a column titled 'url' (for QGIS purposes).
During a GetFeatureInfo request served through OpenLayers, which returns the table of information in question, is it possible to have a URL 'hyperlink' and open a new browser tab?
Answer
You have to use a freemarker template in Geoserver with a content that converts the urls to hyperlinks. See the docs: http://docs.geoserver.org/stable/en/user/tutorials/GetFeatureInfo/index.html#tutorials-getfeatureinfo
This website contains an example that looks quite useful: http://longwayaround.org.uk/notes/custom-geoserver-getfeatureinfo-template/
Example section of the content.ftl
<#list features as feature>
${feature.type.title}
<#list feature.attributes as attribute><#if !attribute.isGeometry>
- ${attribute.name?replace("_", " ", "i")?cap_first}:
<#if attribute.value?starts_with('http')>
${attribute.value}<#else>
${attribute.value}
#if>
#if>
#list>undefined
undefined undefined#list>undefined
But you could also just set up a rule in your content.ftl so that the content of a specific column is used as a hyerlink.
No comments:
Post a Comment