コンテンツにスキップ

ヒートマップ

android-heatmap モジュールは、MapConductor 用の地図実装非依存なヒートマップオーバーレイを提供します。 タイルベースのラスターレイヤーとしてヒートマップデータをレンダリングするため、あらゆる地図プロバイダ(Google Maps、MapLibre、Mapbox、ArcGIS、HERE など)で動作します。

dependencies {
implementation(platform("com.mapconductor:mapconductor-bom:1.1.3"))
implementation("com.mapconductor:core")
implementation("com.mapconductor:heatmap")
// 地図プロバイダを選択
implementation("com.mapconductor:for-googlemaps")
}

任意の XxxMapView のコンテンツブロック内に HeatmapOverlay を配置し、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,
)
}
}

大規模なデータセットには、HeatmapPoints を使って一括更新します:

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

HeatmapOverlayState を使うとランタイムでヒートマップのプロパティを変更できます:

val heatmapState = remember {
HeatmapOverlayState(
radiusPx = 20,
opacity = 0.7,
gradient = HeatmapGradient.DEFAULT,
)
}
// 動的に変更
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)
}
パラメータデフォルト説明
radiusPxInt20各ポイントのぼかし半径(ピクセル)
opacityDouble0.7レイヤーの不透明度(0.0〜1.0)
gradientHeatmapGradientHeatmapGradient.DEFAULTカラーグラデーション
maxIntensityDouble?null正規化の最大強度(null の場合は自動計算)
プロパティデフォルト
radiusPxInt20
opacityDouble0.7
gradientHeatmapGradientHeatmapGradient.DEFAULT
maxIntensityDouble?null
weightProvider(HeatmapPointState) -> Double{ it.weight }

位置 0.2 のグリーン(#66E100)→ 位置 1.0 のレッド(#FF0000)。