{ //required"alphaMultiplier":1,//A float between 0 and 1"radius":numberMapping,//A mapping that assigns a float"width":numberMapping,//A mapping that assigns a float"fill": colorMapping/iconMapping/patternMapping ,//A mapping that assigns a hex color, pattern or icon//optional"popOver":{"color": colorMapping,"text":stringMapping},//A mapping that assigns a string "dashedLine":[numberMapping, numberMapping],//An array with two mappings that assign a float"borderColor":colorMapping,//A mapping that assigns a hex color"elevation":numberMapping,//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 seeded random color, this mapping can only be used to assign hex colors{"type":"seededRandom",//should be seededRandom"expressionObject": {"expression":"2*property1+1","properties":["myProperty"]} ,//An expression to use as seed to create a random hex color}
//Assign a target based on conditions {"type":"caseMap",//must be caseMap"defaultTarget":target //A target object of type color, number, pattern or icon. See documentation below"caseMap": [ {"expressionObject": {"expression":"property1<0","properties":["myProperty"]} ,//An expression to evaluate"target": target //A target object of type color, number, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend }, {"expressionObject": {"expression":"property1==1","properties":["myProperty"]} ,//An expression to evaluate"target": target //A target object of type color, number, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend }, {"expressionObject": {"expression":"property1>2","properties":["myProperty"]} ,//An expression to evaluate"target": target //A target object of type color, number, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend } ],}
//Assign a target based on ranges of an expression . {"type":"rangeMap",//must be rangeMap"gradient":true,//Boolean indicating whether to apply a gradient to the mapping"expressionObject":{"expression":"2*property1+1","properties":["myProperty"]},//expression which outcome to apply the rangeMap to"defaultTarget":target,//A target object of type color, number, pattern or icon. See documentation below"rangeMap": [ {"value":1,//Start of the range"target": target //A target object of type color, number, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend }, {"value":2,//Start of the range"target": target //A target object of type color, number, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend }, {"value":3,//Start of the range"target": target //A target object of type color, number, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend } ],}
//Assign a target based on values of an expression.{"type":"valueMap",//must be valueMap"expressionObject":{"expression":"property1","properties":["myProperty"]},//expression which outcome to apply the valueMap to"defaultTarget":target,//A target object of type color, number, pattern or icon. See documentation below"valueMap": [ {"value":1,//Value to map"target": target //A target object of type color, float, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend }, {"value":2,//Value to map"target": target //A target object of type color, float, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend }, {"value":3,//Value to map"target": target //A target object of type color, float, pattern or icon. See documentation below"label":"label"//An optional label to use in the legend } ],}
//Always assign the same target.{"type":"constant",//must be constant"target":target,//A target object of type color, number, pattern, icon or string. See documentation below}
// Assing the expression as a target{"type":"expression","defaultTarget":target,//A target object of type color, number, pattern, icon or string. See documentation below"expressionObject":{properties:["myProperty"],"expression":"2*property1+1"}}
Expressions
An expressionObject is an object that consists of a properties and an 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:
The values should be an array of strings. Each element in the array should be any string value you want to use in the expression.
For example if your layer contains features with properties "constructionMaterial", "Height", and "housingType" then your values array can be:
values = ["flat", "concrete"]
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",... and the values as "value1", "value2"...
For example:
expression="property1==value1 && property3>5"
Here property1 refers to the first element in the properties array which is in this case "housingType", the second to "Height" and value1 refers to the string "flat". That is to say the expression results in true for all features with housing type "flat" and altitude higher than 3 and false otherwise.
The expression can contain standard operators such as:
*,+,-,/, round(_), floor(_), ceil(_),),(
and logical operators such as:
and, or, not, ==,<=,<,>,>=,!=
An expressionObject can simply assign the value of a property:
An expression can also be used to apply more complicated logic. For example finding the population density based on the properties "surfaceArea" and "population":