Adding AddMarkerOverlay, which allows the user to put markers on the map when double tapping

pull/7/head
Arthur VALIN 2 years ago
parent debb6ca2a6
commit eb9e174728

@ -0,0 +1,31 @@
package uca.baptistearthur.geocaching.ui.overlay
import android.graphics.Rect
import android.util.Log
import android.view.MotionEvent
import org.osmdroid.util.GeoPoint
import org.osmdroid.views.MapView
import org.osmdroid.views.overlay.Overlay
class AddMarkerOverlay : Overlay() {
private var locations: MutableSet<GeoPoint> = mutableSetOf()
override fun onDoubleTap(e: MotionEvent?, mapView: MapView?): Boolean {
Log.d("GeoMap", "Longpress")
val proj = mapView?.projection;
if(proj!=null){
val loc = proj.fromPixels(e?.x?.toInt()!!, e?.y?.toInt() !! ) as GeoPoint
locations.add(loc)
val marker = PlaceMarker(mapView, locations)
marker.position = loc
marker.title = "Step " + locations.size
mapView.overlays.add(marker)
mapView.invalidate()
}
return true;
}
}
Loading…
Cancel
Save