onClick does not occur on onDrag start, and onRelease added that occu… #18
@ -66,6 +66,12 @@ fun App() {
|
|||||||
pointTwo.second + (end.focus.longitude - start.focus.longitude).toDegrees()
|
pointTwo.second + (end.focus.longitude - start.focus.longitude).toDegrees()
|
||||||
false// returning false, because when we are dragging circle we don't want to drag map
|
false// returning false, because when we are dragging circle we don't want to drag map
|
||||||
} else true
|
} else true
|
||||||
|
},
|
||||||
|
onRelease = {
|
||||||
|
println("On drag ended $this")
|
||||||
|
},
|
||||||
|
onClick = {
|
||||||
|
println("On CLick $this")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
|
@ -22,8 +22,9 @@ public data class MapViewConfig(
|
|||||||
val onDrag: (start: MapViewPoint, end: MapViewPoint) -> Boolean = { _, _ -> true },
|
val onDrag: (start: MapViewPoint, end: MapViewPoint) -> Boolean = { _, _ -> true },
|
||||||
val onViewChange: MapViewPoint.() -> Unit = {},
|
val onViewChange: MapViewPoint.() -> Unit = {},
|
||||||
val onSelect: (GmcBox) -> Unit = {},
|
val onSelect: (GmcBox) -> Unit = {},
|
||||||
|
val onRelease: MapViewPoint.() -> Unit = {},
|
||||||
val zoomOnSelect: Boolean = true,
|
val zoomOnSelect: Boolean = true,
|
||||||
val resetViewPoint: Boolean = false
|
val resetViewPoint: Boolean = false,
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -141,9 +141,6 @@ public actual fun MapView(
|
|||||||
selectRect = null
|
selectRect = null
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val dragStart = change.position
|
|
||||||
val dpPos = DpOffset(dragStart.x.toDp(), dragStart.y.toDp())
|
|
||||||
config.onClick(MapViewPoint(dpPos.toGeodetic(), viewPoint.zoom))
|
|
||||||
drag(change.id) { dragChange ->
|
drag(change.id) { dragChange ->
|
||||||
val dragAmount = dragChange.position - dragChange.previousPosition
|
val dragAmount = dragChange.position - dragChange.previousPosition
|
||||||
val dpStart =
|
val dpStart =
|
||||||
@ -174,6 +171,15 @@ public actual fun MapView(
|
|||||||
val newViewPoint = viewPoint.zoom(-change.scrollDelta.y.toDouble() * config.zoomSpeed, invariant)
|
val newViewPoint = viewPoint.zoom(-change.scrollDelta.y.toDouble() * config.zoomSpeed, invariant)
|
||||||
config.onViewChange(newViewPoint)
|
config.onViewChange(newViewPoint)
|
||||||
viewPointInternal = newViewPoint
|
viewPointInternal = newViewPoint
|
||||||
|
}.onPointerEvent(PointerEventType.Release) {
|
||||||
|
val change = it.changes.first()
|
||||||
|
val (xPos, yPos) = change.position
|
||||||
|
val dpOffset = DpOffset(xPos.toDp(), yPos.toDp())
|
||||||
|
config.onRelease(MapViewPoint(dpOffset.toGeodetic(), viewPoint.zoom))
|
||||||
|
}.onPointerEvent(PointerEventType.Press) {
|
||||||
|
val dragStart = it.changes.first().position
|
||||||
|
val dpPos = DpOffset(dragStart.x.toDp(), dragStart.y.toDp())
|
||||||
|
config.onClick(MapViewPoint(dpPos.toGeodetic(), viewPoint.zoom))
|
||||||
}.fillMaxSize()
|
}.fillMaxSize()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user