Viewers

A viewer is the base in which a map is created, with different layers of data. That data may either be provided by planviewer, other mapping services or your data uploaded by yourselves;

List viewers

GET /maps_api/v2/server/viewers

Returns an overview of the viewers currently created, ordered by creation date. The newest one will be returned first.

Query Parameters:
 
  • limit (integer) – A number between 1 and 200, indicating the maximum number of viewers returned per page.
  • offset (integer) – Start showing viewers at this offset.

Note

To use the integer and offset parameters, those must be given as query parameters like https://www.planviewer.nl/maps_api/v2/server/viewers?limit=1&offset=1

Example request:

GET /maps_api/v2/server/viewers?limit=1 HTTP/1.1
Host: planviewer.nl
Accept: application/json

Example response:

{
    "viewers": [
        {
            "self_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
            "name": "Voorbeeld",
            "identifier": "138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
            "created_at": "2018-04-03T11:30:44+02:00",
            "updated_at": "2018-04-03T11:36:03+02:00"
        }
    ],
    "total_count": 2,
    "current_count": 1,
    "limit": 1,
    "offset": 0,
    "error": false,
    "next": {
        "url": "https://www.planviewer.nl/maps_api/v2/server/viewers?limit=1&offset=1",
        "offset": 1,
        "limit": 1
    }
}

Response fields

Integer total_count:
 The total number of viewers for the given application.
Integer current_count:
 The number of viewers returned by the call
Integer offset:The number of viewer to start from, based on the creation_date ordening
Integer limit:The maximimum number of viewers that would be returned by this call
Object next:next:url is the next api call to make, to fetch the next amount of viewers.

Create a new viewer

POST /maps_api/v2/server/viewers

Create a new viewer. This request may either be sent with a JSON body or a form url-encoded body. You must specify the Content-Type header. See the examples for some usage.

Request JSON Object:
 
  • name (string) – A string specifying the name for the viewer (can be used to distinguish viewers for users).
  • default_show_print (boolean) – A boolean (true or false) to indicate whether printing is possible in this viewer.
  • default_show_reset (boolean) – A boolean (true or false) to indicate whether the view of the viewer can be reset by the user.
  • default_show_measure (boolean) – A boolean (true or false) to indicate whether a measuring tool is available to the user.
  • default_show_snap (boolean) – A boolean (true or false) to indicate whether the snapping tool is available to the user.
  • use_postmessage (boolean) – A boolean (true or false) to indicate whether the viewer’s Postmessage function is used
  • default_use_gps (boolean) – A boolean (true or false) to indicate whether the viewer will request GPS coordinate from the user to load to that location
  • gps_target_button (boolean) – A boolean (true or false) to indicate whether the viewer will display a GPS target button to allow users to go to their GPS location
  • use_search (boolean) – A boolean (true or false) when true will display a searchbar above the feature info
  • limit_extent (boolean) – A boolean (true or false) will limit panning of the map to just beyond the set outline. limiting tiling calls.
  • start_zoom_level (integer) – A integer (-15 - 15) value to adjust the starting zoom level up (minus) or down (plus).
  • info_text (string) – (optional) A block of html code that will replace our default text in the feature block.

Example JSON request:

POST /maps_api/v2/server/viewers HTTP/1.1
Host: planviewer.nl
Accept: application/json
Content-Type: application/json

{
    "name": "example",
    "default_show_print": true,
    "default_show_reset": false,
    "default_show_measure": true,
    "default_show_snap": true,
    "use_postmessage": true,
    "default_use_gps": false,
    "gps_target_button": true,
    "use_search": true,
    "limit_extent": true,
    "start_zoom_level": 5,
    "info_text": "<div class=\"Example\">Hello World</div>"
}

Example form request:

POST /maps_api/v2/server/viewers HTTP/1.1
Host: planviewer.nl
Accept: application/json
Content-Type: application/x-www-form-urlencoded

name=example&default_show_print=true&default_show_reset=false&default_show_measure=true

Example response:

{
    "error": false,
    "viewer": {
        "has_dossier_outline": false,
        "self_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/layers",
        "delete_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/delete",
        "update_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "snapshot_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot",
        "outline_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/outline",
        "clone_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/clone",
        "sort_layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/sort_layers",
        "create_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/layers",
        "upload_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/upload",
        "viewer_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/viewer/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "outline_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/dossier/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "name": "example",
        "identifier": "138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "default_show_print": true,
        "default_show_reset": false,
        "default_show_measure": true,
        "default_show_snap": true,
        "use_postmessage": true,
        "default_use_gps": false,
        "gps_target_button": true,
        "use_search": true,
        "limit_extent": true,
        "start_zoom_level": 5,
        "info_text": "<div class=\"Example\">Hello World</div>",
        "created_at": "2018-04-03T11:30:44+02:00",
        "updated_at": "2018-04-03T11:36:03+02:00"
    }
}

Response fields

  • indentifier:
    The id of the viewer, needed for maintaining the layers

Get a viewer’s details

GET /maps_api/v2/server/viewers/(string: identifier)

Get the specifics and details of a viewer given an identifier for some viewer.

Parameters:
  • identifier (string) – Identifier of the viewer for which to retrieve details.

Example request:

GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae HTTP/1.1
Host: planviewer.nl
Accept: application/json

Example response:

{
    "error": false,
    "viewer": {
        "has_dossier_outline": true,
        "self_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/layers",
        "delete_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/delete",
        "update_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "snapshot_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot",
        "outline_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/outline",
        "clone_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/clone",
        "sort_layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/sort_layers",
        "create_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/layers",
        "upload_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/upload",
        "viewer_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/viewer/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "outline_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/dossier/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "name": "example",
        "identifier": "138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "default_show_print": true,
        "default_show_reset": false,
        "default_show_measure": true,
        "default_show_snap": true,
        "use_postmessage": true,
        "default_use_gps": false,
        "gps_target_button": true,
        "use_search": true,
        "limit_extent": true,
        "start_zoom_level": 5,
        "info_text": "<div class=\"Example\">Hello World</div>",
        "created_at": "2018-04-03T11:30:44+02:00",
        "updated_at": "2018-04-03T11:36:03+02:00"
    }
}

Update the viewer details

PATCH /maps_api/v2/server/viewers/(string: identifier)

Update the details of an existing viewer. Alternatively you can use the POST or PUT http methods, but you will need to specify all form fields in that case. This request may either be sent with a JSON body or a form url-encoded body. You must specify the Content-Type header. See the examples for some usage.

Parameters:
  • identifier (string) – Identifier of the viewer for which to update details.
Request JSON Object:
 
  • name (string) – Optional: A string specifying the name for the viewer (can be used to distinguish viewers for users).
  • default_show_print (boolean) – Optional: A boolean (true or false) to indicate whether printing is possible in this viewer.
  • default_show_reset (boolean) – Optional: A boolean (true or false) to indicate whether the view of the viewer can be reset by the user.
  • default_show_measure (boolean) – Optional: A boolean (true or false) to indicate whether a measuring tool is available to the user.
  • default_show_snap (boolean) – A boolean (true or false) to indicate whether the snapping tool is available to the user.
  • use_postmessage (boolean) – A boolean (true or false) to indicate whether the viewer’s Postmessage function is used
  • default_use_gps (boolean) – A boolean (true or false) to indicate whether the viewer will request GPS coordinate from the user to load to that location
  • gps_target_button (boolean) – A boolean (true or false) to indicate whether the viewer will display a GPS target button to allow users to go to their GPS location.
  • use_search (boolean) – A boolean (true or false) when true will display a searchbar above the feature info
  • limit_extent (boolean) – A boolean (true or false) will limit panning of the map to just beyond the set outline. limiting tiling calls.
  • start_zoom_level (integer) – A integer (-15 - 15) value to adjust the starting zoom level up (minus) or down (plus).
  • info_text (string) – (optional) A block of html code that will replace our default text in the feature block.

Example JSON request:

PATCH /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae HTTP/1.1
Host: planviewer.nl
Accept: application/json
Content-Type: application/json

{
    "default_show_print": false
}

Example form request:

PATCH /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae HTTP/1.1
Host: planviewer.nl
Accept: application/json
Content-Type: application/x-www-form-urlencoded

default_show_print=false

Example response:

{
    "error": false,
    "viewer": {
        "has_dossier_outline": true,
        "self_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/layers",
        "delete_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/delete",
        "update_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "snapshot_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot",
        "outline_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/outline",
        "clone_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/clone",
        "sort_layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/sort_layers",
        "create_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/layers",
        "upload_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/upload",
        "viewer_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/viewer/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "outline_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/dossier/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "name": "example",
        "identifier": "138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae",
        "default_show_print": false,
        "default_show_reset": false,
        "default_show_measure": true,
        "default_show_snap": true,
        "use_postmessage": true,
        "default_use_gps": false,
        "gps_target_button": true,
        "use_search": true,
        "limit_extent": true,
        "start_zoom_level": 5,
        "info_text": "<div class=\"Example\">Hello World</div>",
        "created_at": "2018-04-03T11:30:44+02:00",
        "updated_at": "2018-04-03T11:36:03+02:00"
    }
}

Clone the viewer details

POST /maps_api/v2/server/viewers/(string: identifier)/clone

Clone a viewer. The details of the new viewer will be returned, it will be a copy of the original.

Parameters:
  • identifier (string) – Identifier of the viewer to clone.

Example request:

POST /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/clone HTTP/1.1
Host: planviewer.nl
Accept: application/json

Example response:

{
    "error": false,
    "viewer": {
        "has_dossier_outline": true,
        "self_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e",
        "layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/layers",
        "delete_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/delete",
        "update_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e",
        "snapshot_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/snapshot",
        "outline_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/outline",
        "clone_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/clone",
        "sort_layers_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/sort_layers",
        "create_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/layers",
        "upload_layer_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e/upload",
        "viewer_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/viewer/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e",
        "outline_embed_url": "https://www.planviewer.nl/maps_api/v2/embed/dossier/210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e",
        "name": "example (kopie)",
        "identifier": "210c96664f73e8c5c2eb485568083083f9d7d7f125b0258360cd0c5bb2a9445e",
        "default_show_print": false,
        "default_show_reset": false,
        "default_show_measure": true,
        "use_postmessage": true,
        "default_show_snap": true,
        "default_use_gps": false,
        "gps_target_button": true,
        "use_search": true,
        "limit_extent": true,
        "start_zoom_level": 5,
        "info_text": "<div class=\"Example\">Hello World</div>",
        "created_at": "2018-04-03T11:30:44+02:00",
        "updated_at": "2018-04-03T11:36:03+02:00"
    }
}

Delete the viewer

DELETE /maps_api/v2/server/viewers/(string: identifier)/delete

Delete the viewer specified.

Parameters:
  • identifier (string) – Identifier of the viewer to delete.

Example request:

DELETE /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/delete HTTP/1.1
Host: planviewer.nl
Accept: application/json

Example response:

{
    "error": false
}

Create a viewer snapshot

GET /maps_api/v2/server/viewers/(string: identifier)/snapshot

Get a snapshot image of the current state of the viewer. Optionally, the format may be specified using a .(png|jpg) postfix at the end of the url. Note however that the Accept header and format query parameter will override this. If no format is specified, a png image will be returned.

Note

This call will return an image source.

Parameters:
  • identifier (string) – Identifier of the viewer.
Query Parameters:
 
  • format (string) – Optional. If this is specified, this will override the format specified in the Accept header. Allowed values are: png and jpg.
  • base_layer (int) – Optional. By default the first base layer available is used, if another layer is specified that layer will be used for the snapshot instead. This query parameter should contain the id of the base layer to be used.
  • width (int) – Optional. The width of the image, between 10 and 3000 pixels.
  • height (int) – Optional. The height of the image, between 10 and 3000 pixels.
Request Headers:
 
  • Accept – The returned image will have the format specified by this header, unless a format was specified using the format query parameter. Accepted values are: image/png and image/jpeg.

Example requests:

Using the Accept header:

GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot HTTP/1.1
Host: planviewer.nl
Accept: image/png

Using the format query parameter:

GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot?format=png HTTP/1.1
Host: planviewer.nl

Specify other parameters:

GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot?width=2000&height=2000&base_layer=1 HTTP/1.1
Host: planviewer.nl
Accept: image/png

Get the outline for the viewer

GET /maps_api/v2/server/viewers/(string: identifier)/outline

Get the outline geometry of the viewer. By default the format returned will be GeoJSON. Optionally, the format may be specified using a .(json|gml|txt) extension at the end of the url.

Parameters:
  • identifier (string) – Identifier of the viewer.

Example requests:

Using the Accept header to get the EWKT:

GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/outline HTTP/1.1
Host: planviewer.nl
Accept: text/plain

Using the format at the end of the url to get GeoJSON:

GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/outline.json HTTP/1.1
Host: planviewer.nl

Set the outline for the viewer

POST /maps_api/v2/server/viewers/(string: identifier)/set_outline

Set or update the outline geometry of the viewer. The given coordinates will overwrite the current outline.

Parameters:
  • identifier (string) – Identifier of the viewer.
  • type (string) – Type of polygon POLYGON or MULTIPOLYGON
  • coordinates (string) – string of coordinates

Example JSON request Polygon:

POST /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/set_outline HTTP/1.1
Host: planviewer.nl
Accept: application/json
Content-Type: application/json

{
    "type": "Polygon",
    "coordinates": "(191432.850617455 445495.775797824, 189148.050617455 445119.455797824, 189094.290617455 442243.295797824, 192534.930617455 441759.455797824, 193878.930617455 444098.015797824, 191432.850617455 445495.775797824)"
}

Example JSON request MultiPolygon:

POST /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/set_outline HTTP/1.1
Host: planviewer.nl
Accept: application/json
Content-Type: application/json

{
    "type": "Multipolygon",
    "coordinates": "((191432.850617455 445495.775797824, 189148.050617455 445119.455797824, 189094.290617455 442243.295797824, 192534.930617455 441759.455797824, 193878.930617455 444098.015797824, 191432.850617455 445495.775797824)),
    ((191432.850617455 445495.775797824, 189148.050617455 445119.455797824, 189094.290617455 442243.295797824, 192534.930617455 441759.455797824, 193878.930617455 444098.015797824, 191432.850617455 445495.775797824))"
}

Note

The coordinates given should be based in EPSG:28992 (RD New - Netherlands) to ensure correct placement in the viewers