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-label: List viewers ------------ .. http: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 integer limit: A number between 1 and 200, indicating the maximum number of viewers returned per page. :query integer offset: 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:** .. sourcecode:: http GET /maps_api/v2/server/viewers?limit=1 HTTP/1.1 Host: planviewer.nl Accept: application/json **Example response:** .. sourcecode:: json { "viewers": [ { "self_url": "https://www.planviewer.nl/maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae", "name": "Voorbeeld", "identifier": "138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae", "active": true, "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. :boolean use_local_storage: Set on true to make the viewer remember the settings from local storage. .. _create-viewers-label: Create a new viewer ------------------- .. http: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. :Hello World", "active": true, "display_form": "popup" } **Example form request:** .. sourcecode:: http 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:** .. sourcecode:: json { "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": "
Hello World
", "active": true, "display_form": "popup", "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 ---------------------- .. http:get:: /maps_api/v2/server/viewers/(string:identifier) Get the specifics and details of a viewer given an identifier for some viewer. :param string identifier: Identifier of the viewer for which to retrieve details. **Example request:** .. sourcecode:: http GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae HTTP/1.1 Host: planviewer.nl Accept: application/json **Example response:** .. sourcecode:: json { "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": "
Hello World
", "active": true, "created_at": "2018-04-03T11:30:44+02:00", "updated_at": "2018-04-03T11:36:03+02:00" } } Update the viewer details ------------------------- .. http: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. :param string identifier: Identifier of the viewer for which to update details. :Hello World", "active": true, "display_form": "default", "created_at": "2018-04-03T11:30:44+02:00", "updated_at": "2018-04-03T11:36:03+02:00" } } Clone the viewer details ------------------------ .. http: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. :param string identifier: Identifier of the viewer to clone. **Example request:** .. sourcecode:: http POST /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/clone HTTP/1.1 Host: planviewer.nl Accept: application/json **Example response:** .. sourcecode:: json { "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": "
Hello World
", "active": true, "display_form": "default", "created_at": "2018-04-03T11:30:44+02:00", "updated_at": "2018-04-03T11:36:03+02:00" } } Delete the viewer ----------------- .. http:delete:: /maps_api/v2/server/viewers/(string:identifier)/delete Delete the viewer specified. :param string identifier: Identifier of the viewer to delete. **Example request:** .. sourcecode:: http DELETE /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/delete HTTP/1.1 Host: planviewer.nl Accept: application/json **Example response:** .. sourcecode:: json { "error": false } Create a viewer snapshot ------------------------ .. http: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. :param string identifier: Identifier of the viewer. :query string format: Optional. If this is specified, this will override the format specified in the ``Accept`` header. Allowed values are: ``png`` and ``jpg``. :query int base_layer: 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. :query int width: Optional. The width of the image, between 10 and 3000 pixels. :query int height: Optional. The height of the image, between 10 and 3000 pixels. :reqheader 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:* .. sourcecode:: http GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot HTTP/1.1 Host: planviewer.nl Accept: image/png *Using the format query parameter:* .. sourcecode:: http GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/snapshot?format=png HTTP/1.1 Host: planviewer.nl *Specify other parameters:* .. sourcecode:: http 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 ------------------------------ .. http: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. :param string identifier: Identifier of the viewer. **Example requests:** *Using the Accept header to get the EWKT:* .. sourcecode:: http 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:* .. sourcecode:: http GET /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/outline.json HTTP/1.1 Host: planviewer.nl .. _viewers-set_outline: Set the outline for the viewer ------------------------------ .. http: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. :param string identifier: Identifier of the viewer. :param string type: Type of polygon POLYGON or MULTIPOLYGON or ewkt :param string coordinates: string of coordinates **Example JSON request Polygon:** .. sourcecode:: http 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:** .. sourcecode:: http 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))" } **Example JSON request Ewkt:** .. sourcecode:: http POST /maps_api/v2/server/viewers/138230fef76a818207720794e9a5c7db1ac243e9f42471737ccae5becfd7a2ae/set_outline HTTP/1.1 Host: planviewer.nl Accept: application/json Content-Type: application/json { "type": "ewkt", "coordinates": "SRID:28992;POLYGON((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