Calculate the area covered by a polygon in a google map in an Android App

∥☆過路亽.° 提交于 2019-11-30 16:20:45
L. G.

A method doing this is posted in following answer:

https://stackoverflow.com/a/16210785/891479

This is based on following formula:

http://mathworld.wolfram.com/PolygonArea.html

http://en.wikipedia.org/wiki/Polygon

Principle of plolygon area calculation using this formula:

http://maruzar.blogspot.com/2011/12/irregular-and-regular-polygon-area-by.html

If you want to do it yourself, the way to calculate any polygn area knowing the corrdinates is explained in Polygon.

You can find a more comprehensive explanation in How to Calculate the Area of a Polygon under the topic Irregular Polygons

androidseb

Just in case it helps someone, there is a very good answer in this thread: Calculate the area of a polygon drawn on google maps in an Android application

The answer from Marian Paździoch:

There's already a library for that.

import com.google.maps.android.SphericalUtil;

//...

List<LatLng> latLngs = new ArrayList<>();
latLngs.add(new LatLng(51.893728, -8.491865));
latLngs.add(new LatLng(51.893550, -8.492479));
latLngs.add(new LatLng(51.893216, -8.492224));
latLngs.add(new LatLng(51.893404, -8.491598));
Log.i(TAG, "computeArea " + SphericalUtil.computeArea(latLngs));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!