1. List Layers
  2. Get Layer
  3. Create Layer
  4. Update Layer
  5. Delete Layer
  6. Render Layer
  7. Export Layer
  8. List Layer Features

/layers

List Layers

URL:  /layers 

Method: GET

Protocol: HTTP, HTTPS

Returns:

  • 200 (OK) – collection of layers

Example:

$ curl -X GET http://api.giscloud.com/1/layers

<layers>
  <layer>
    <id>4</id>
    <name>afall_madagascar</name>
    <owner>1</owner>
    <source>{"type":"file","src":"/c4ca4238a0b923820dcc509a6f75849b/public/afall_madagascar.mif","name":"afall_madagascar.mif"}</source>
    <onscale/>
    <offscale/>
    <label/>
    <x_min>4740255.255951</x_min>
    <x_max>5661692.948624</x_max>
    <y_min>-2948274.180564</y_min>
    <y_max>-1268147.963255</y_max>
    <textfield/>
    <alpha>61</alpha>
    <encoding/>
    <margin/>
    <created>1304248967</created>
    <visible>t</visible>
    <lock>f</lock>
    <raster>f</raster>
    <grp/>
    <exportable>t</exportable>
    <parent/>
    <tooltip/>
    <hidegeometry>f</hidegeometry>
    <merged>f</merged>
    <map_id>2</map_id>
    <type>polygon</type>
    <order>5</order>
    <modified>1312718747</modified>
  </layer>
</layers>

Get Layer

URL:  /layers/{id} 

Method: GET

Protocol: HTTP, HTTPS

Parameters: id – layer to be retrieved

Example:

$ curl -X GET http://api.giscloud.com/1/layers/1

<layer>
  <id>4</id>
  <name>afall_madagascar</name>
  <owner>1</owner>
  ...
</layer>

Create Layer

URL:  /layers 

Method: POST

Protocol: HTTPS

Returns:

  • 201 (Created) + a URL to the newly created resource in the Location header of the response

Example:

$ curl -X POST https://api.giscloud.com/1/layers

Adding vector layer from the database.

$ curl -H "Content-Type: application/json" -X POST -d '{"mid": <MAP_ID>,"name":"<LAYER_NAME>","type":"point","source":"{\"type\":\"pg\",\"src\":\"<TABLE_NAME>\"}"}' "https://api.giscloud.com/1/layers.json?api_key=<API_KEY>" -v

Update Layer

URL:  /layers/{id} 

Method: PUT

Protocol: HTTPS

Returns one of:

  • 204 if successful
  • 404 if the resource wasn’t found

Delete Layer

URL:  /layers/{id} 

Method: DELETE

Protocol: HTTPS

Parameters:

  • id – layer to be deleted

Returns one of:

  • 204 (No Content) if successful
  • 404 (Not Found) if the resource wasn’t found

Render Layer

Produces layer rendered as image (png,jpg) or as interactive map in an iframe.

URL:  /layers/{id}/render.{format} 

Method: GET

Protocol: HTTP, HTTPS

Parameters:

  • id – layer to be rendered
  • format – png, jpg, iframe
  • width – width in pixels, default 256px (iframe 100%)
  • height – height in pixels, default 256px (iframe 100%)
  • invalidate – invalidate image (only png,jpg)

Returns:

  • 200 (OK) + a binary image or html

Notice: Format iframe produces Iframe HTML tag that renders map in the viewer

Example:

$ curl -X GET http://api.giscloud.com/1/layers/2/render.png?width=64&;height=64&;invalidate=1
...binary...

$ curl -X GET http://api.giscloud.com/1/layers/2/render.iframe?width=500
<iframe src="http://beta.giscloud.com/embed/?map=4&;layer=2&;bound=-20037508.34279,-44927335.4271,20037508.34279,18469844.56059"
     width="500" height="100%" frameborder="0"></iframe>

Export Layer

URL:  /layers/{id}/export.{format}  

Method: GET

Protocols: HTTP, HTTPS

Parameters:

  • id – layer to be exported
  • format – shp, mif, kml, gpx, dxf, gml, csv (optional .zip)
  • zip – delivers result in a zip archive (optional)

Notice: If result of export is more than 1 file result will be stored into a zip archive and delivered in that way

Returns:

  • 200 (OK) + exported file

Example:

$ curl -X GET http://api.giscloud.com/1/layers/2/export.shp
filename: world.shp.zip
...binary...

$ curl -X GET http://api.giscloud.com/1/layers/2/export.kml.zip
filename: world.kml.zip
...binary...

$ curl -X GET http://api.giscloud.com/1/layers/2/export.kml
filename: world.kml
...binary...