Examples

Measure distance and length of feature
Measure distance and length of feature

This example shows how you can calculate length of line and area of polygon by using MaplibreMeasureControl when you input a line or a polygon.

Adding default GeoJSON feature to TerraDraw
Adding default GeoJSON feature to TerraDraw

You can add GeoJSON features by using addFeatures() function in the TerraDraw instance which can be retrieved through getTerraDrawInstance() function.

Adding GeoJSON feature to TerraDraw custom style
Adding GeoJSON feature to TerraDraw custom style

You can add GeoJSON features with custom style by using addFeatures() function in the TerraDraw instance which can be retrieved through getTerraDrawInstance() function.

Subscribe select event of TerraDraw
Subscribe select event of TerraDraw

This plugin provides a function getTerraDrawInstance to fetch the instance of TerraDraw itself. Using this instance, you can use all APIs supported by TerraDaraw. For example, the below code is to subscribe TerraDraw's select event to show selected feature as GeoJSON string.

Customising drawing options
Customising drawing options

This plugin tries to optimise the better drawing options for each Terra Draw mode. However, preconfigured drawing options might not be desired for your app. For example, if you only want to use polygon control,but you don't want users to drag a polygon or adding/deleting a node on an edge of a polygon, the following setting can be done.

Use different coordinate precisiion
Use different coordinate precisiion

TerraDraw usesd 9 digits as default coordinate precision. You can use different coordinate precision instead.

Using custom icon
Using custom icon

This plugin provides default icons for each TerraDraw mode button. You can change default icon if you would like to use your own.

Query elevation from Maplibre Terrain
Query elevation from Maplibre Terrain

This example shows how you can calculate length of line and query elevation from maplibre raster-dem terrain source.

Query elevation directly from TerrainRGB
Query elevation directly from TerrainRGB

This example shows how you can calculate length of line and query elevation from custom TerrainRGB DEM dataset.

Customising drawing style
Customising drawing style

The plugin use default color styling provided by TerraDraw. This example shows you how to customise drawing style.