I use the pointermoved functionality in a .NET app and was wondering if something similar is available for Android? I have an android device that has a smart stylus and would like to handle the movements (pointer over) above the map if at all possible. I haven't done extensive research as of yet, but curious as to if anyone had some info. thanks!
Solved! Go to Solution.
Actually figured it out. setOnHoverListener() did the trick:
mapView.setOnHoverListener(object:View.OnHoverListener { override fun onHover(v:View, event:MotionEvent):Boolean { val screenPoint = android.graphics.Point( Math.round(event!!.x), Math.round(event!!.y) ) val mapPoint = mapView.screenToLocation(screenPoint) when (event.getAction()) { MotionEvent.ACTION_HOVER_ENTER -> hover_text.text ="entered the map at (x: ${mapPoint.x}, y: ${mapPoint.y})" MotionEvent.ACTION_HOVER_MOVE -> hover_text.text = "currently hovering on (x: ${mapPoint.x}, y: ${mapPoint.y})" MotionEvent.ACTION_HOVER_EXIT -> hover_text.text ="no longer hovering, left the map at (x: ${mapPoint.x}, y: ${mapPoint.y}))" } return false } })
Yes, but before I answer the question can you confirm which SDK you are using. Are you using Android as with Android Studio, or writing a Xamarin cross platform app with Visual Studio?
Mark, thanks for the reply! Yes using ArcGIS Runtime for Android (100.6) with Android Studio 3.5.
So the PointerMoved method you've seen is probably a specific method for working with WPF controls.
As a start I'd take a look at this sample to see some basics of interacting with MapViews in Android controls:
Feature Layer Selection | ArcGIS for Developers
It shows you how you can implement a touch listener.
Thanks! I may check into the setCapturePointerListener method to see what it does.
Actually figured it out. setOnHoverListener() did the trick:
mapView.setOnHoverListener(object:View.OnHoverListener { override fun onHover(v:View, event:MotionEvent):Boolean { val screenPoint = android.graphics.Point( Math.round(event!!.x), Math.round(event!!.y) ) val mapPoint = mapView.screenToLocation(screenPoint) when (event.getAction()) { MotionEvent.ACTION_HOVER_ENTER -> hover_text.text ="entered the map at (x: ${mapPoint.x}, y: ${mapPoint.y})" MotionEvent.ACTION_HOVER_MOVE -> hover_text.text = "currently hovering on (x: ${mapPoint.x}, y: ${mapPoint.y})" MotionEvent.ACTION_HOVER_EXIT -> hover_text.text ="no longer hovering, left the map at (x: ${mapPoint.x}, y: ${mapPoint.y}))" } return false } })