Search code examples
androidandroid-mapviewarcgis

Android Arcgis 100.3: How to get center Point of MapView


How to get Point from ArcGis's MapView center of the screen, which representing its latitude and longitude?


Solution

  • float centreX=mapView.getX() + mapView.getWidth()  / 2;
    float centreY=mapView.getY() + mapView.getHeight() / 2;
    
    android.graphics.Point screenPoint = new android.graphics.Point(Math.round(centreX), Math.round(centreY));
    Point mapPoint = mv.screenToLocation(screenPoint);
    Point wgs84Point = (Point) GeometryEngine.project(mapPoint, SpatialReferences.getWgs84());
    
    double lat = wgs84Point.getY();
    double lng = wgs84Point.getX();