I develop an android app with the use of ArcGIS map and what im trying to do is to get the lat and long of the last screen touch. I searched for information in the Esri forum and found a solution that advises to use it:
fun getLocation() {
var viewPoint= mapView.getCurrentViewpoint(Viewpoint.Type.CENTER_AND_SCALE)
var scale=viewPoint.targetScale
//var long=??
//var lat=??
}
but i found only the sacle(zoom in or out) at the last touch of the user and i want also the latitude and longtitude of it.
how do i get them from the viewpoint class or maybe from the mapview class
Thanks for any help.
The viewpoint returned by GetCurrentViewpoint
uses the mapView's SpatialReference (probably EPSG:3857 in your case).
Not sure about kotlin but here is how I converted it using ArcGIS .net SDK:
var viewPoint = mapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);
var latlon = (MapPoint)GeometryEngine.Project(viewPoint.TargetGeometry, SpatialReferences.Wgs84);
var lat = latlon.Y;
var lon = latlon.X;