Skip to content
Torben Barsballe edited this page Jun 2, 2015 · 17 revisions

API for managing maps (represented in GeoServer admin as a LayerGroup).

/api/maps/<workspace>

  • GET - list available maps

/api/maps/<workspace>/<map>

  • GET - complete map definition

  • POST - create new map

  • PUT - replace definition of existing map

  • PATCH - updating existing map with partial definition

  • DELETE - remove indicated map

/api/maps/<workspace>/<map>/copy

  • PUT - copy an existing map

/api/maps/<workspace>/<map>/bounds

  • PUT - calculate the bounds of an existing map in a given projection

/api/maps/<workspace>/<map>/layers

  • GET - list of layer references, in order displayed by map

  • PATCH - replace lost of layer references

  • POST - append one (or more) layer references

/api/maps/<workspace>/<map>/layers/<name>

  • GET - access an individual layer by name or index

  • DELETE - remove an individual layer by name or index

Related "Reflector" GeoServer API:

/geoserver/wms/reflect?layers=<workspace>:<map>&format=application/openlayers

Map List

Get Maps

List maps available in a workspace.

HTTP 200 OK

[ { "name" : <name>,
    "workspace" : <workspace>
    "title": <title>,
    "description" : <description>,
    "proj": <proj>,
    "bbox": <bbox>,
    "projectionExtent": <extent>,
    "layer_count": 13,
    "timeout": 1000,
    "modified": "Mon, 06 Oct 2014 16:21:53 GMT"
  }
  <map summary>
]

Each <map summary> provides details sufficient for listing available maps:

  • bbox is the Bounding box of all the layers in the map, calculated using the SRS defined by proj.
  • projectionExtent is the cannonical projection extent of the SRS.
  • layer_count includes both layers and group layers
  • metadata: author, created, modified, change and timeout are optional
    • modified is filled in from file handle so you have something

HTTP 404

  • notfound

Map

Map GET

Map definition including list of layers.

HTTP 200 OK

Map definition suitable for editing.

  • contained groups describe mode and layer_count
  • contained layers indicate which resource
  • additional metadata can be added, such as background

HTTP 400

  • notfound

Map POST

Creates a new map.

  • POST api/maps//
  {"name": "foo",
   "proj": "epsg:4326",
   "abstract": "Spatial data courtesy of the City of Medford \<http://medford.org\>"
  }

HTTP 200 OK

Resulting map definition.

HTTP 400

  • notfound:

DELETE Map

Deletes an existing map.

  • DELETE /api/maps/{workspace}/{map}

HTTP 200

  {"title": "foo"}

PUT Map <a name="put"/a>

Edits an existing map.

  • PUT /api/maps/{workspace}/{map}
    {
        "proj":"epsg:3587"
        "bbox":{"west":180,"east":180,"south"90,"north"90:}
    }

A partial map definition (as shown above). Can include any or all attributes of a map. Note that bbox and proj are meaningless without each other, although if only proj is included, then bbox will be automatically calculated based on the layers in the layer group.

HTTP 200

Representation of modified map.

HTTP 404

  • notfound

Map Copy <a name="copy"/a>

Copies an existing map.

  • PUT api/maps/{workspace}/{map}/copy
  {"name": "foo",
   "copylayers": "true",
   "layers": [...]
  }

Where:

  • name: The name of the copy
  • copylayers: Boolean flag to copy all the layers, or use the existing layers in the new map. Optional, defaults to true.
  • layers: List of layers to rename. Elements have the same syntax as the Copy Layer API. Only applies if copylayers=true. If any layers are not provided, renaming defaults to <oldlayername>-<map> where <map> is the first three letters of the map name.

Map Bounds <a name="bounds"/a>

Calculates the bounds of an existing map in a given projection.

  • PUT api/maps/{workspace}/{map}/bounds
  {"proj": "EPSG:4326"}

Calculates the net bounds (aggregated layer bounds) of the map in the projection given by proj. The calculated bounds will be in the same units as this projection. If a projection is not given, uses the current projection of the map.

HTTP 200 The calculated bounds:

    {
        "proj": {
            srs:"epsg:3587",
            wkt: ...,
            ...
        },
        "bbox": {
            native: {
                "west":180,"east":180,"south":90,"north":90,
                "center":[...]
            },
            lonlat: {
                "west":180,"east":180,"south":90,"north":90,
                "center":[...]
            }
        }
    }

HTTP 404

  • not found: layer reference does not match a published layer
  • bad request: invalid CRS

Map Layer List

List Layer References

List of layers used by map, in order displayed.

HTTP 200

  • List of layer references in order displayed

HTTP 404

  • notfound

List Layer References PUT

Replace the references in the list of layers (can be used to bulk move references, add references or remove references).

PUT:

  • PUT [/api/maps/{workspace}/{map}/layers]
{  { workspace=<workspace>,
     name=<layer>},
   <reference>
}

Where:

  • reference: provides a workspace and name used to locate a published layer

Notes:

Removing references listed in a Map does not delete the published layer (your layer and style remain unmodified and available for use in other Maps).

HTTP 200

List of layers after modification.

HTTP 404

  • not found: layer reference does not match a published layer
  • bad request: adding two references for the same published layer
  • bad request: removing the last layer

List Layer References Post

Append one (or more) layer references.

  • POST [/api/maps/{workspace}/{map}/layers]
{  { workspace=<workspace>,
     name=<layer>},
   <reference>
}

Where:

  • reference: provides a workspace and name used to locate a published layer

HTTP 200

List of layers after modification (see GET).

HTTP 404

  • not found: layer reference does not match a published layer
  • bad request: adding two references for the same published layer

Map Layer Reference

Get Map Layer Reference

Access an individual layer by name or index.

Delete Map Layer Reference

Remove an individual layer by name or index.

  • DELETE [/api/maps/{workspace}/{map}/layers/{name}]

HTTP 200

{ name: <name>
  removed: <boolean>
}

HTTP 404

  • not found: layer reference does not match a published layer
  • bad request: adding two references for the same published layer

Clone this wiki locally