Upcoming vector styles

Description

Adds a vector style.

Endpoint

/path/{pathId}/vector/style

Method

POST

Access Level Rules

Minimum Access Level

edit+

Processing Units

Minimum processing units

2

Parameters

Name
Description
Required
Default

pathId

The id of the vector layer.

true

name

The name of the style to add.

true

parameters

The parameters for the style. See details below.

true

description

A description of the style as string.

false

Default null.

The parameters should have the following form:

{    //required
    "alphaMultiplier": 1,//A float between 0 and 1
    "radius":valueMapping, //A mapping that assigns a float
    "width":valueMapping, //A mapping that assigns a float
    "fill": colorMapping/iconMapping/patternMapping , //A mapping that assigns a hex color, pattern or icon
    //optional
    "dashedLine":[valueMapping, valueMapping], //An array with two mappings that assign a float
    "borderColor":colorMapping, //A mapping that assigns a hex color
    "elevation":valueMapping, //A mapping that assings a value
}

Aside from the alphaMultiplier which should be a float, all properties in the parameters should be mappings. These mappings should be objects. There is a couple of mapping types you can use. All of these types are listed in the table below.

//Sent an expression to a color by hashing it, this mapping can only be used to assing hex colors
{
    "type": "hashMap", //should be hashMap
    "expressionObject": {"expression":"2*property1+1", "properties":["myProperty"]} , //An expression to hash to a hex color
}

Expressions

An expressionObject is an object that consists of a properties and an expression.

expressionObject = {"properties":properties, "expression":expression}

The properties should be an array of strings. Each element in the array should be the name of a property of the features within the layer that you are styling.

For example if your layer contains features with properties "constructionMaterial", "Height", and "housingType" then your properties array can be:

properties = ["housingType", "constructionMaterial","Height"]

The expression should be a string that can be interpreted as a formula or logical expression outputting either a number or boolean.

You can use the values of the properties array by referencing them as "property1", "property2",...

For example:

expression="and(property1=='wood', property3>5)"

Here property1 refers to the first element in the properties array which is in this case "housingType" and the second to "Height". That is to say the expression results in true for all features with building material wood and altitude higher than 3 and false otherwise.

The expression can contain standard operators such as:

*,+,-,/, floor(_),),(

and logical operators such as:

&&, ||, !, ==,<=,<,>,>=,!=

An expressionObject can simply assign the value of a property:

expressionObject = {"properties":["housingType"]:,"expression":"property1"}

Or an expression can also simply be a number:

expressionObject={"properties":[], "expression":"1"}

Or boolean:

expressionObject ={"properties":[], "expression":"true"}

An expression can also be used to apply more complicated logic. For example finding the population density based on the properties "surfaceArea" and "population":

expressionObject = {"properties":["surfaceArea", "population"]:,"property2/property1"}

We can also make a more complicated logical expression:

expressionObject = {"properties":["surfaceArea", "population"]:,"property2!= 2 && property1 > 5"}

Target

A target is an object that can be of type color, pattern, icon or number. It signifies the value that is being assigned by the mapping.

In case of a colorMapping the target should be of type color, in case of a patternMapping of type pattern etc.

target = {type:"color/pattern/icon/number", "color":null, "pattern":null, "icon":null, "number":null}

In case of type color the target needs to contain a hex color:

target = {"type":"color", "color":"#99f53f"}

In case of type number the target needs to contain a number:

target = {"type":"number", "number":3.2}

In case of type pattern the target must contain a pattern

targetObject = {"type":"pattern", "pattern":pattern}

A pattern must be an object with:

  • type: One of solid, diagonal, horizontal or vertical

  • width: a float between 1 and 50

  • backgroundColor: a hex color, optional.

Example:

pattern = {"type":"diagonal", "width": 2, "backgroundColor":"#934314"}

Alternatively the pattern can be an object of type drive. In this case you need to include a pathId of a png that is stored on the Drive.

Example:

pattern = {"type":"drive", "pathId":"4d695990-ace7-434e-b703-e1d5ae006800"}

In this case the png will be used as pattern.

In case of type icon the target must contain an icon

targetObject = {"type":"icon", "icon":icon}

An icon must be an object with

  • name: the name of the icon as a string.

All valid inputs for name can be listed with

GET /image/listIcons

Example:

icon = {"name":"dog"}

Alternatively the icon can be an object of type drive. In this case you need to include a pathId of a png that is stored on the Drive.

Example:

pattern = {"type":"drive", "pathId":"4d695990-ace7-434e-b703-e1d5ae006800"}

In this case the png will be used as icon.

Last updated