source.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. .. _mbstyle_source:
  2. Publishing a GeoServer Layer for use with Mapbox Styles
  3. =======================================================
  4. GeoServer can be configured to serve layers as vector tiles to be used as sources for Mapbox styles rendered by client-side applications such as OpenLayers.
  5. 1. :ref:`production_container.enable_cors` in GeoServer.
  6. 2. Install the :ref:`Vector Tiles <vectortiles.install>` extension.
  7. 3. Follow the :ref:`vectortiles.tutorial` to publish your layers in ``application/vnd.mapbox-vector-tile`` format (You only need to do the "Publish vector tiles in GeoWebCache" step).
  8. Once these steps are complete, you will be able to use your GeoServer layers in any Mapbox-compatible client application that can access your GeoServer.
  9. Source
  10. ------
  11. The source syntax to use these GeoServer layers in your MapBox Style is::
  12. "<source-name>": {
  13. "type": "vector",
  14. "tiles": [
  15. "http://localhost:8080/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS
  16. &VERSION=1.0.0&LAYER=<workspace>:<layer>&STYLE=&TILEMATRIX=EPSG:900913:{z}
  17. &TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile
  18. &TILECOL={x}&TILEROW={y}"
  19. ],
  20. "minZoom": 0,
  21. "maxZoom": 14
  22. }
  23. .. note::
  24. ``<workspace>`` and ``<layer>`` should be replaced by the workspace and name of the layer in question. ``{x}``, ``{y}``, and ``{z}`` are placeholder values for the tile indices and should be preserved as written.
  25. .. note::
  26. ``<source-name>`` should be replaced by a source name of your choice. It will be used to refer to the source when defining a layer in the Mapbox Style.
  27. .. note::
  28. If geoserver is not being served from ``localhost:8080``, update the domain accordingly.