Skip to Content
ExamplesShape Overlays (Polygon, Circle, Heatmap, Cluster, Polyline)

Shape Overlays

The SDK provides a set of shape overlay APIs for drawing custom geometry on the map. These overlays are independent of routes and navigation — they can be freely added and removed at any time.

Polygon

Draw filled polygons with customizable fill and stroke styling.

val polygon = LzPolygonModel( identifier = "restricted-zone", coordinates = listOf( LatLng(-33.45, -70.66), LatLng(-33.45, -70.65), LatLng(-33.44, -70.65), LatLng(-33.44, -70.66) ), fillColor = "#7000FF", fillOpacity = 0.3f, strokeColor = "#7000FF", strokeWidth = 3.0f, strokeOpacity = 1.0f ) lzMap.addPolygon(polygon) // Update in place (same identifier) lzMap.addPolygon(polygon.copy(fillOpacity = 0.6f)) // Remove lzMap.removePolygon("restricted-zone") // Remove all polygons at once lzMap.removeAllPolygons()

Circle Layer

Render multiple circle markers from a list of coordinates with shared styling.

val circles = LzCircleModel( identifier = "poi-points", coordinates = poiLocations, // List<LatLng> radius = 10f, color = "#FF9800", opacity = 0.9f, strokeColor = "#FFFFFF", strokeWidth = 2f ) lzMap.addCircleLayer(circles) lzMap.removeCircleLayer("poi-points")

Heatmap

Visualize point density with a color gradient. Points can carry optional weights (0.0-1.0) to influence density.

val heatmap = LzHeatmapModel( identifier = "foot-traffic", points = trafficPoints, weights = trafficWeights, // Optional: List<Double> intensity = 1.5, // Density multiplier radius = 25f, // Blur radius in dp opacity = 0.7f ) lzMap.addHeatmap(heatmap) lzMap.removeHeatmap("foot-traffic")

The default color ramp transitions from transparent blue through green, yellow, orange, to red.

Clusters

Group nearby points into clusters that expand as the user zooms in. Supports multiple tiers with different colors and sizes based on point count.

val cluster = LzClusterModel( identifier = "stores", points = storeLocations, clusterRadius = 50, // Pixel radius for grouping clusterMaxZoom = 22, // Max zoom for clustering unclusteredColor = "#2196F3", unclusteredRadius = 6f, clusterColors = listOf("#4CAF50", "#FF9800", "#F44336"), clusterRadii = listOf(20f, 30f, 40f), clusterThresholds = listOf(0, 10, 50) ) lzMap.addCluster(cluster) lzMap.removeCluster("stores")

The clusterThresholds define tier boundaries: tier 0 covers 0-9 points (green), tier 1 covers 10-49 points (orange), tier 2 covers 50+ points (red).

Polyline

Draw standalone lines that are independent of navigation routes. Supports solid and dashed patterns.

// Solid line val solidLine = LzPolylineModel( identifier = "boundary", coordinates = boundaryPoints, color = "#2196F3", width = 4f ) lzMap.addPolyline(solidLine) // Dashed line val dashedLine = LzPolylineModel( identifier = "perimeter", coordinates = perimeterPoints, color = "#F44336", width = 3f, dashArray = listOf(10f, 5f) // 10dp dash, 5dp gap ) lzMap.addPolyline(dashedLine) lzMap.removePolyline("boundary")

Notes

  • All shape overlays use a unique identifier string for add/remove operations.
  • Calling add*() with an existing identifier updates the shape in place.
  • Shapes are drawn on top of map tiles but below markers.
  • Colors use hex format (e.g., "#FF0000", "#7000FF").
  • Coordinates use org.maplibre.android.geometry.LatLng.
Last updated on