GeoServer added UTFGrid output for vector features starting from the 2.9-beta version. It is implemented as a WMS service output format.

After installing GeoServer 2.9-beta, adding a datastore with a PostGIS connection and publishing a layer that contains vector features, I can click the WMS UTFGrid entry from the available formats list on the Layer Preview page in the admin UI and indeed get a UTFGrid representation of my data displayed in the browser.

How can I now integrate this as a UTFGrid layer into OpenLayers 3? The only resource that I could find on this topic is this official example. However, it uses ol.source.TileUTFGrid as the layer's source and passes a URL which ends in .json. GeoServer, however, publishes a WMS URL which expects further parameters such as request, bbox etc.

Simply passing the URL generated by the Layer Preview page gives Uncaught SyntaxError: Unexpected token : in the browser's console.

What would be the correct way to include GeoServer's UTFGrid output as a layer?


The URL you pass to ol.source.TileUTFGrid is a metadata url in TileJSON format, which will be requested through JSONP. Not sure if GeoServer can answer that. Then, tile URLs use an XYZ template, which GeoServer could provide through its integrated GeoWebCache, if that has support for TileJSON already.

That said, the current implementation of ol.source.TileUTFGrid is not perfectly suited for use with GeoServer. It would have to be made more flexible in terms of configuration options.

  • Okay, I see. Do you know another way how I could get UTFGrid data from PostGIS in a format that is supported by OpenLayers 3? Is this what this approach with Mapnik and TileStache is about?
    – Dirk
    Mar 23 '16 at 18:01
  • GeoServer can also offer regular 256x256 UTFGrid tiles via its WMTS endpoint. There is also a pull request adding WMS/UTFGrid support to OL2, but it got no attention (I guess OL2 is jus not supported anymore) github.com/openlayers/ol2/pull/1486 Mar 24 '16 at 7:35
  • Thanks for confirming Andrea. So to make OpenLayers 3 work with GeoServer, all we'd need is an alternate way to specify the layer configuration (i.e. a local TileJSON object instead of requesting it through JSONP).
    – ahocevar
    Mar 24 '16 at 16:34
  • 1
    Pull request created: github.com/openlayers/ol3/pull/5120.
    – ahocevar
    Mar 24 '16 at 16:45
  • Does anybody know how to properly set up GeoServer to provide the required WMTS endpoint that matches the example from the pull request? I have the assumption that this is not activated by default.
    – Dirk
    Apr 4 '16 at 16:20

Hav a look at all these URLs

GetFeatureInfo from TileUTFGrid with XYZ based tileJSON source

GetFeatureInfo from TileUTFGrid with WMS based tileJSON source

using OpenLayers-3.21.0



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.