Skip to content

Heatmap

El módulo android-heatmap proporciona un overlay de mapa de calor independiente de la implementación de mapa para MapConductor. Renderiza los datos del mapa de calor como una capa raster basada en tiles y funciona con cualquier proveedor de mapas (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,
)
}
}

Para conjuntos de datos grandes, usa HeatmapPoints para agregar todos los puntos en una sola actualización:

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

Usa HeatmapOverlayState para controlar las propiedades del mapa de calor en tiempo de ejecución:

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.