endian11
2020-09-15 389853ce971a3da0e806dddd909bb43f5928c90c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package safeluck.drive.evaluation.arcgis
 
import android.content.Context
import android.graphics.Point
import android.view.MotionEvent
import android.widget.Toast
import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener
import com.esri.arcgisruntime.mapping.view.MapView
 
/**
 *
 * @ProjectName: DriveJudge
 * @Package: safeluck.drive.evaluation.arcgis
 * @ClassName: MapSingleTapListener
 * @Description: java类作用描述
 * @Author: 李占伟
 * @CreateDate: 20/7/16 下午5:12
 * @UpdateUser: 更新者
 * @UpdateDate: 20/7/16 下午5:12
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
 
class MapSingleTapListener(context: Context, mapView: MapView) : DefaultMapViewOnTouchListener(context, mapView) {
    private var mContext: Context = context
    val TAG = MapSingleTapListener::class.java.canonicalName
    override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
        var mapPoint =  mMapView.screenToLocation(e?.x?.toInt()?.let { Point(it, e.y.toInt()) })
        showMessage(String.format("User tapped on the map at (%.3f,%.3f)", mapPoint.getX(), mapPoint.getY()))
        return true
    }
 
    private fun showMessage(message: String) {
        Toast.makeText(mContext,message,Toast.LENGTH_SHORT).show()
    }
}