Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add circleClickEvents() #131

Merged
merged 1 commit into from
May 4, 2021
Merged
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
24 changes: 19 additions & 5 deletions maps-ktx/src/main/java/com/google/maps/android/ktx/GoogleMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public fun GoogleMap.cameraEvents(): Flow<CameraEvent> =
}

/**
<<<<<<< HEAD
* A suspending function that awaits the completion of the [cameraUpdate] animation.
*
* @param cameraUpdate the [CameraUpdate] to apply on the map
Expand Down Expand Up @@ -146,7 +145,7 @@ public fun GoogleMap.cameraIdleEvents(): Flow<Unit> =
setOnCameraIdleListener {
offerCatching(Unit)
}
awaitClose{
awaitClose {
setOnCameraIdleListener(null)
}
}
Expand All @@ -162,7 +161,7 @@ public fun GoogleMap.cameraMoveCanceledEvents(): Flow<Unit> =
setOnCameraMoveCanceledListener {
offerCatching(Unit)
}
awaitClose{
awaitClose {
setOnCameraMoveCanceledListener(null)
}
}
Expand All @@ -177,7 +176,7 @@ public fun GoogleMap.cameraMoveEvents(): Flow<Unit> =
setOnCameraMoveListener {
offerCatching(Unit)
}
awaitClose{
awaitClose {
setOnCameraMoveListener(null)
}
}
Expand All @@ -204,11 +203,26 @@ public fun GoogleMap.cameraMoveStartedEvents(): Flow<Unit> =
setOnCameraMoveStartedListener {
offerCatching(Unit)
}
awaitClose{
awaitClose {
setOnCameraMoveStartedListener(null)
}
}

/**
* Returns a flow that emits when a circle is clicked. Using this to observe circle clicks events
* will override an existing listener (if any) to [GoogleMap.setOnCircleClickListener].
*/
@ExperimentalCoroutinesApi
public fun GoogleMap.circleClickEvents(): Flow<Circle> =
callbackFlow {
setOnCircleClickListener {
offerCatching(it)
}
awaitClose {
setOnCircleClickListener(null)
}
}

/**
* Builds a new [GoogleMapOptions] using the provided [optionsActions].
*
Expand Down