Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/android-for-maptiler.api
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public final class com.mapconductor.maptiler.MapTilerMapViewControllerInterface$
public final class com.mapconductor.maptiler.MapTilerMapViewControllerMarkerTilesKt {
public static final com.mapconductor.maptiler.marker.MapTilerMarkerTileRenderer tileRenderer(com.mapconductor.maptiler.MapTilerMapViewController);
public static final java.lang.Object renderTiledMarkers(com.mapconductor.maptiler.MapTilerMapViewController, java.util.List<com.mapconductor.core.marker.MarkerState>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
public static final boolean handleMarkerTap(com.mapconductor.maptiler.MapTilerMapViewController, com.mapconductor.core.features.GeoPoint, double);
public static final boolean handleMarkerTap(com.mapconductor.maptiler.MapTilerMapViewController, com.mapconductor.core.features.GeoPoint);
public static final com.mapconductor.core.marker.MarkerRenderingSupport<java.lang.Object> createMarkerRenderingSupport(com.mapconductor.maptiler.MapTilerMapViewController);
}
public final class com.mapconductor.maptiler.MapTilerMapViewHolder implements com.mapconductor.core.map.MapViewHolderInterface<com.maptiler.maptilersdk.map.MTMapViewController, com.maptiler.maptilersdk.map.MTMapViewController> {
Expand Down Expand Up @@ -294,6 +294,7 @@ public final class com.mapconductor.maptiler.marker.MapTilerMarkerTileRenderer {
public final com.mapconductor.core.raster.RasterLayerState render(java.util.List<com.mapconductor.core.marker.MarkerState>);
public final java.lang.String getRasterLayerId();
public final void clear();
public final com.mapconductor.core.marker.MarkerState findMarkerAt(com.mapconductor.core.features.GeoPointInterface, kotlin.jvm.functions.Function1<? super com.mapconductor.core.features.GeoPointInterface, androidx.compose.ui.geometry.Offset>);
public final com.mapconductor.core.marker.MarkerState findMarkerAt(com.mapconductor.core.features.GeoPointInterface, double);
}
final class com.mapconductor.maptiler.marker.MapTilerMarkerTileRenderer$Companion {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/mapconductor/maptiler/MapTilerMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fun MapTilerMapSurface(
// MapTiler のタイルレンダラでヒットテストするのでここで先に見る。
val markerHit =
runCatching {
controller.handleMarkerTap(point, mtController.getZoom())
controller.handleMarkerTap(point)
}.getOrDefault(false)
if (!markerHit && !controller.dispatchOverlayTap(point)) {
onClick?.invoke(point)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ internal suspend fun MapTilerMapViewController.renderTiledMarkers(data: List<Mar
* 流さない(他プロバイダと同じ)。
*
* @param point タップ座標。
* @param nativeZoom MapTiler ネイティブズーム。
* @return マーカーがタップを消費したら true。
*/
internal fun MapTilerMapViewController.handleMarkerTap(
point: GeoPoint,
nativeZoom: Double,
): Boolean {
val state = markerTileRenderer?.findMarkerAt(point, nativeZoom) ?: return false
val state = markerTileRenderer?.findMarkerAt(point, holder::toScreenOffset) ?: return false
// clickable = false のマーカーは透過させる(コアの clickableOnly と同じ方針)。
if (!state.clickable) return false
state.onClick?.invoke(state)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.mapconductor.maptiler.marker

import com.mapconductor.core.InternalMapConductorApi
import com.mapconductor.core.marker.MarkerHitPick
import androidx.compose.ui.geometry.Offset
import com.mapconductor.core.features.GeoPointInterface
import com.mapconductor.core.marker.MarkerEntity
import com.mapconductor.core.marker.MarkerManager
Expand All @@ -10,10 +13,10 @@ import com.mapconductor.core.raster.RasterLayerSource
import com.mapconductor.core.raster.RasterLayerState
import com.mapconductor.core.raster.TileScheme
import com.mapconductor.core.tileserver.TileServerRegistry
import java.util.UUID
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.sqrt
import java.util.UUID

/**
* 大量マーカー(「Bunch of Markers」等)を、他モジュール(maplibre 等)と同じ方式=
Expand Down Expand Up @@ -93,8 +96,31 @@ class MapTilerMarkerTileRenderer(
}

/**
* タップ座標付近のマーカーを返す(クリック用の簡易ヒットテスト)。
* タップ座標に当たるマーカーを返す。選び方はコアの [MarkerHitPick.pick] と同じで、
* 指の下にアイコンかラベルが描かれているマーカーが、先端の近い別のマーカーより優先する。
*
* @param project 地理座標をビューの画面座標へ投影する(holder の toScreenOffset)。
*/
@OptIn(InternalMapConductorApi::class)
fun findMarkerAt(
tap: GeoPointInterface,
project: (GeoPointInterface) -> Offset?,
): MarkerState? {
if (markers.isEmpty()) return null
val touchScreen = project(tap) ?: return null
val bounds = MarkerHitPick.searchBounds(tap, touchScreen, project) ?: return null
val candidates = markers.filter { bounds.contains(it.position) }
return MarkerHitPick.pickBy(touchScreen, candidates, { it }, project)
}

/**
* 旧来の判定(先端からの距離だけを見る)。ラベルやアイコンの大きさを見ないので、
* 指の下に描かれているマーカーより先端の近い別のマーカーを選ぶことがある。
*/
@Deprecated(
"先端からの距離だけで選ぶ旧来の判定。findMarkerAt(tap, project) を使う。",
ReplaceWith("findMarkerAt(tap, project)"),
)
fun findMarkerAt(
tap: GeoPointInterface,
nativeZoom: Double,
Expand Down
Loading