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?

example image of url served after GetFeatureInfo request

  • What about if you use Mapserver? – Jon Apr 28 '17 at 18:49

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

<ul><#list features as feature>
        <ul><#list feature.attributes as attribute><#if !attribute.isGeometry>
            <li>${attribute.name?replace("_", " ", "i")?cap_first}:
        <#if attribute.value?starts_with('http')>
                <a href="${attribute.value}">${attribute.value}</a><#else>


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.

| improve this answer | |
  • 1
    Nice Thomas, thanks. Continued research that supplements this response led me to this website: geoext.org/pipermail/users/2011-July/002412.html, which discusses how the features' attributes may be controlled on the app side (in my case, using GeoExt). – Scott Close Feb 9 '15 at 18:59
  • That's also a good idea ;) – Thomas B Feb 9 '15 at 20:51
  • FWI for anyone who lands here after OL3 has been introduced, the freemarker templates still apply... if you use geoserver's native html output to populate the attribute table. If you instead you request a json response, or text or other, it's easy it intercept the url field and pre/append html a href tags, and it works beautifully – Scott Close Feb 18 '16 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.