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

Support for tap regions #118

Open
mburns-acom opened this issue Jun 13, 2024 · 2 comments
Open

Support for tap regions #118

mburns-acom opened this issue Jun 13, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@mburns-acom
Copy link

Hello,
First we are using com.qozix.tileview.TileView, but want to move to a newer library to mitigate the risk of using an older library that is not supported.
Since we are using Compose heavily this library caught my eye.
My Question: do you think this library would be able to extended to support a tap listener when a tap occurs in a rectangle (and the rectangle may cross tiles)? In a map scenario, image that you have metadata about the map and that you want to display a bottomsheet that changes the info displayed as the user taps on areas of the image. For example they tap near a city name and info about the city is displayed.
The tap region would not be visible (no marker, callout, or path). It would virtual data associated with the image.
I guess I could implement MapUI.content. Yes?

@p-lr
Copy link
Owner

p-lr commented Jun 14, 2024

The library can be extended to support regions. Since regions are basically closed paths which may be filled or not, stroked or not, and for which tap evens are handled inside the geometries (not on the paths).
Recently, a user requested to add such tap listeners on paths (in other words, treat them as regions). I postponed this because I believe the library should have first class support for regions.

In the meantime, you could use the onTap api:

/**
 * Registers a tap callback for tap gestures. The callback is invoked with the relative coordinates
 * of the tapped point on the map.
 * Note: the tap gesture is detected only after the [ViewConfiguration.doubleTapMinTimeMillis] has
 * passed, because the layout's gesture detector also detects double-tap gestures.
 */
fun MapState.onTap(tapCb: (x: Double, y: Double) -> Unit) {
    this.tapCb = tapCb
}

Basically, every time the user makes a tap on the map, you know the relative coordiantes of the tap. Since you have the data of your regions (including their geometries), you can check whether the tap is inside your regions or not. This is more code on your side, but this would be an alternative before the library introduces support for regions.

@p-lr p-lr added the enhancement New feature or request label Jun 14, 2024
@mburns-acom
Copy link
Author

Thank you for a quick response. Have a great weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants