b = geometry_name.setProperty(property_name, property_value);
The
Geometry.setProperty function modifies the value associated with the
Geometry object's property specified by the string expression
property_name. The property will be modified to the value given in the string or numeric expression
property_value. Properties may not be applied to empty Geometry objects so you must first call the
Geometry.load,
Geometry.tracePolygon, or
Geometry.walkPolygon functions to add items to the Geometry before setting properties. Property names are case sensitive.
When a geometry item contains multiple features, the property is set to
property_value in ALL of the features of the geometry. When a geometry item is saved to a GeoJSON file using the
Geometry.save function, the properties are written to the GeoJSON file.
When displaying the geometry on a map, the following properties may be set to change the visual styling of the vector items:
Name | Value |
stroke | Color used to draw lines and polygon outlines as an HTML color string (e.g. "#FF0000"). |
stroke-width | Width of the lines and outlines of polygons in display pixels. |
fill | Color used to draw the interior of polygons as an HTML color string (e.g. "#FF0000"). |
The function returns a logical value of 1 (true) because it will always successfully set a property.
// Declare a geometry
Geometry outline;
// Have the user walk the outline of a polygon
if outline.walkPolygon() then
// Add the ID items of the case as properties to make it easier to identify when importing into GIS system
// PROV, DIST and HHNO are the names used in the GIS system
outline.setProperty("PROV", PROVINCE);
outline.setProperty("DIST", DISTRICT);
outline.setProperty("HHNO", HOUSEHOLD_NUMBER);
// Save the outline to a GeoJSON file
outline.save("outline.geojson");
endif;
// Declare a map
Map mymap;
// Load geometry from a file
Geometry boundary;
boundary.load("boundary.geojson");
// Set the polygon fill color to purple
boundary.setProperty("fill", "#94219");
// Set the outline color to red
boundary.setProperty("stroke", "#ff0000");
// Set the outline width to 3
boundary.setProperty("stroke-width", 3);
// Add geometry to the map
numeric geometryId = mymap.addGeometry(boundary);
// Show the map
mymap.show();