經過android gps採集的座標爲球面座標,若是此種座標造成的ploygon直接進行面積的計算是不可行的,計算出來的面積爲負數。因而須要將球面座標轉換成平面座標在進行計算方可。java
public static double getArea(List<Point> list, MapView mapView) { DecimalFormat dfAreaR = new DecimalFormat("0.00"); Polygon polygon = new Polygon(); for (int i = 0; i < list.size(); i++) { Point pt = list.get(i); if (i == 0) { polygon.startPath(pt); } else { polygon.lineTo(pt); } } polygon.closeAllPaths(); SpatialReference webMercator = SpatialReference.create(2362); //project from wgs84 Polygon newPoly = (Polygon) GeometryEngine.project(polygon, mapView.getSpatialReference(),webMercator); double area = newPoly.calculateArea2D(); return Double.valueOf(dfAreaR.format(area)); }