Search code examples
javaandroidpointarcgisesri

Android-Java Point(android.graphics.point) in Point cannot be applied to (Double, Double)


I am using ArcGis solution to get current location of the user. Whenever I want to getLongitude and getLatitude it gives an error that point cannot be converted to Double.

How to solve this problem?

Point curLocation;
final SpatialReference wm = SpatialReference.create(102100);
final SpatialReference egs = SpatialReference.create(4326);



public void onLocationChanged(Location location) {
        if (location == null)
            return;

        boolean zoomToMe = (curLocation == null);
        curLocation = new Point(location.getLongitude());

        if (zoomToMe) {
            Point p = (Point) GeometryEngine.project(curLocation, egs, wm);
            mMapView.zoomToResolution(p, 5.0);
        }
    }

It says INT tho but still :(


Solution

  • A point takes two ints as parameters. You're passing it a single double. You can use PointF which takes 2 floats, but even that will lose data.

    Are you using a different library (arcgis comes up in a web search) that uses a custom Point class? If so, make sure you're importing the correct version of Point:

    import com.esri.core.geometry.Point;