p-lr / MapCompose

A fast, memory efficient Jetpack Compose library to display tiled maps, with support for markers, paths, and rotation.
Apache License 2.0
220 stars 19 forks source link

Click listener on the map, e.g. to add marker #63

Closed cypher447 closed 2 years ago

cypher447 commented 2 years ago

It would be a nice feature, to have a click/longclick listener on the map, like in OSMdroid and GMaps. It should be fired when clicking on an empty space in the map and allow access to the click position. A common usecase for this is adding a marker at an empty position.

p-lr commented 2 years ago

I completely forgot, but there's already an api for tap gestures using MapState.onTap(tapCb: (x: Double, y: Double) -> Unit). The provided callback receives the normalized coordinates of the tap, which is exactly what you need to place a marker at that position.