Best practice¶
Start at the beginning¶
First we start with creating a viewer and create some layers in that viewer. But before we start, an application must be created. This is done in the planviewer application dashboard.
Here you must name your application. Normally we suggest to name it after your project plan. In this example we will use Example application. Because we make the viewer with API calls, a client and secret is needed. So go to Beveiliging en toegang Select Nieuwe access key
A new access key with a new secret is created. The secret will disappear when you close this screen, so copy it and save it in a save place. It can’t be re-generated.
With this access key , and secret, you get access to the API with HTTP calls.
Our Api works with basic Authetication, which means that per request, an authorization header must be set.
Basic authorization is created with a base64 encode string of the username and password, where the username is the access key and the password is the secret. Then you add the following header with each request:
Header: | Authorization: Basic <base64_encoded_string> |
---|
Create a viewer¶
In order to have a Map, a viewer must be created. A Viewer consist of a outline (Dossiergrens) and layers.
So, lets create a viewer. Use the following call, where name is the project for which you create a Maps application.
create-viewers-label.
You will get a json response which has an identifier key. This identifier is used as viewer identification and is used in every URL, to modify anything for that viewer.
Create an outline¶
To have a project border defined for your project, it’s best to set an outline. When a viewer is initially opened, the viewer will also center on the outline.
An outline is defined by the coordinates of that outline. Create an outline with the following call: Set the outline for the viewer. Alternatively you can draw the ouline in the dashboard.
Create a layer¶
When a viewer is created, there will be 2 basic layers: OpenstreetMap and Aerial. Those layers are used as background for your viewer. Note that only one background layer can be shown at one time, but a user can switch between those layers.
The other layers are created as base for your needs of information.
For this example we will use the layertype BAG (Basisregistratie Adressen en Gebouwen), that we want to use in the viewer.
Use the call Create a new layer for a viewer , name that Bag and use type bag as layer type.
if everything goes well , the layer is created.
You can always check with API if the layer is created with the call List the layers in a viewer