Skip to content

Commit

Permalink
feat: allow to "move" an existing POI from a long press gesture on th…
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Jun 29, 2022
1 parent cc6d7b5 commit fbae401
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion maps/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'kotlin-android'
}

version = "0.6.6"
version = "0.6.7"

android {
compileSdkVersion 31
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ import org.osmdroid.util.GeoPoint
import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.MapEventsOverlay
import org.osmdroid.views.overlay.Marker
import java.util.HashMap
import java.util.UUID

/**
* Edit feature (POI) on the map:
* - by a long pressing gesture on the map
* - by tapping the floating action button
* - by tapping this floating action button
*
* A [Snackbar] may be shown if the current zoom level doesn't meet the minimal editing zoom.
*
* @author [S. Grimault](mailto:sebastien.grimault@gmail.com)
* @author S. Grimault
*/
class EditFeatureButton(
context: Context,
Expand Down Expand Up @@ -103,8 +102,19 @@ class EditFeatureButton(
return false
}

if (listener?.getEditMode() == EditMode.SINGLE && pois.isNotEmpty()) {
return false
if (listener?.getEditMode() == EditMode.SINGLE) {
val mapView = listener?.getMapView() ?: return false

with(pois) {
forEach { poi ->
findMarkerOverlay { it.id == poi.key }?.also {
deselectMarker(it)
it.remove(mapView)
mapView.invalidate()
}
}
clear()
}
}

addPoi(p)
Expand Down Expand Up @@ -251,6 +261,8 @@ class EditFeatureButton(

mapView.overlays.add(poiMarker)
mapView.invalidate()
centerMapToMarker(poiMarker)

pois[poiMarker.id] = poiMarker.position
listener?.onSelectedPOIs(getSelectedPOIs())

Expand Down
4 changes: 2 additions & 2 deletions maps/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Mon Jun 20 22:38:06 CEST 2022
VERSION_CODE=1715
#Wed Jun 29 21:21:09 CEST 2022
VERSION_CODE=1720

0 comments on commit fbae401

Please sign in to comment.