I made a scale bar for my android app using Line.calculateLength2D() and GeometryEngine.distance() (both return the same value), but the value returned does not match distances measured on a physical map using a scale nor google earth's measurements. The points I used to measure were:
Point bottomLeft = MapView.toMapPoint(0, MapView.getHeight());
Point bottomRight = MapView.toMapPoint(MapView.getWidth(), MapView.getHeight());
I also used MapView.getExtent() which gave the same result.
Polygon extent = MapView.getExtent();
Point bottomLeft = extent.getPoint(0);
Point bottomRight = extent.getPoint(1);
I was testing this with the world imagery tile service at zoom level 15. I noticed that wherever I was on earth, the measurement of my screen width was ALWAYS 1032m. I measured the real distance using google earth, and found that the real distance matches ArcGIS's calculateLength2D() value at the equator, but it gets progressively smaller as latitude increases. On a hunch, I tried multiplying the calculateLength2D() value by the cosine of the latitude, and it worked. The product matched google earth measurements at all latitudes.I'm not sure if this is a bug or working as intended. What's the use of calculateLength2D() and distance() if their output is only valid at the equator?