To add a vector layer or vector layer view to the map, first copy the uuid of the vector layer from the geobox portal and get the vector layer from the server: (examples are explained for vector layer, but the same is true for vector layer view.)

getVectorLayer (layer_uuid)

Example:

const vectorLayer = await Server.getVectorLayer ('4f9f3e4b-4dc1-469b-83ab-00ae00f02581');

Then add the vector layer to the map as follows.

addVectorLayer(vectorLayer, options)

Parameters:

vectorLayer is the vector layer or vector layer view that is got from the server.

options (Object)

Name Description
options.selection_color
String?
Sets selection color for this layer. rgb, rgba and hexadecimal values are accepted.
options.highlight_color
String?
Sets highlight color for this layer. rgb, rgba and hexadecimal values are accepted.
options.paint
object?
Object of layer style based on maplibre standard.
options.type
String?
If you want to add the layer with different geometry type, type of geometry in style can be set here. For example, if you want to add a polygon layer as a polyline layer, use ‘Line’.

Choices are: ‘Fill’ | ‘Line’ | ‘Circle’ | ‘Symbol’ | ‘Fill Extrusion’

Returns:

String: Returns a message that shows adding layer was successful or not. Null message means adding was successful.

Example:

const result = await map.addVectorLayer(vectorLayer,{'paint':{'line-color':'#ff0066'},'type':'line','selection_color':'#0000ff','highlight_color':'#003300'});

See the Pen Contact Form – Pen a Day 20 by Geobox (@geobox-gl-demo) on CodePen.1

Leave a comment

Your email address will not be published. Required fields are marked *