Skip to content

Heatmap

The android-heatmap module provides a map-implementation-agnostic heatmap overlay for MapConductor. It renders heatmap data as a tile-based raster layer and works with any map provider (Google Maps, MapLibre, Mapbox, ArcGIS, HERE, etc.).

dependencies {
implementation(platform("com.mapconductor:mapconductor-bom:1.1.3"))
implementation("com.mapconductor:core")
implementation("com.mapconductor:heatmap")
// Choose your map provider
implementation("com.mapconductor:for-googlemaps")
}

Place HeatmapOverlay inside any XxxMapView content block and add points with HeatmapPoint:

XxxMapView(...) {
HeatmapOverlay(
radiusPx = 20,
opacity = 0.7,
) {
HeatmapPoint(
position = GeoPoint(latitude = 35.6762, longitude = 139.6503),
weight = 1.0,
)
HeatmapPoint(
position = GeoPoint(latitude = 35.6895, longitude = 139.6917),
weight = 2.5,
)
}
}

For large datasets, use HeatmapPoints to add all points in a single update:

val pointStates: List<HeatmapPointState> = remember { buildPointList() }
XxxMapView(...) {
HeatmapOverlay(radiusPx = 20) {
HeatmapPoints(pointStates)
}
}

Use HeatmapOverlayState to control heatmap properties at runtime:

val heatmapState = remember {
HeatmapOverlayState(
radiusPx = 20,
opacity = 0.7,
gradient = HeatmapGradient.DEFAULT,
)
}
// Update dynamically
heatmapState.radiusPx = 30
heatmapState.opacity = 0.5
XxxMapView(...) {
HeatmapOverlay(state = heatmapState) {
HeatmapPoints(pointStates)
}
}
val gradient = HeatmapGradient(
listOf(
HeatmapGradientStop(position = 0.0, color = Color.argb(0, 0, 0, 255)),
HeatmapGradientStop(position = 0.5, color = Color.rgb(0, 255, 0)),
HeatmapGradientStop(position = 1.0, color = Color.rgb(255, 0, 0)),
)
)
val heatmapState = remember {
HeatmapOverlayState(gradient = gradient)
}
ParameterTypeDefaultDescription
radiusPxInt20Blur radius of each point in pixels
opacityDouble0.7Layer opacity (0.0–1.0)
gradientHeatmapGradientHeatmapGradient.DEFAULTColor gradient
maxIntensityDouble?nullMax intensity for normalization; auto-calculated if null
PropertyTypeDefault
radiusPxInt20
opacityDouble0.7
gradientHeatmapGradientHeatmapGradient.DEFAULT
maxIntensityDouble?null
weightProvider(HeatmapPointState) -> Double{ it.weight }

Green (#66E100) at position 0.2 → Red (#FF0000) at position 1.0.