[FREE] Calculate areas and distances on maps precisely

The CalculateMapArea, written in Java, is an extension designed for the MIT App Inventor platform. It facilitates drawing and calculating areas on a map. This overview is aimed at users familiar with the block-based language of MIT App Inventor but not necessarily with Java.


  • CalculateMapArea(ComponentContainer container): Initializes the extension with the given component container.

Properties Setters and Getters

  • SetLineMapDraw(boolean isLineString): Defines whether to draw a LineString on the map.
  • GetLineMapDraw(): Returns a boolean indicating if a LineString is being drawn.
  • SetPolygonMapDraw(boolean isPolygon): Sets the drawing mode to polygon if true.
  • SetPolygonMapDraw(): Retrieves the boolean status indicating if the polygon drawing mode is set.

Drawing and Map Component Methods

  • SetMapComponent(Map map): Associates a Map component with the extension for drawing.
  • AddPoint(double latitude, double longitude): Adds a point to the current drawing (polygon or line string) based on latitude and longitude.
  • DrawLineString(): Renders the LineString on the map using the added points.
  • SetLineStyle(int color, int strokeWidth): Defines the style of the line (color and stroke width).
  • SetPolygonStyle(int fillColor, int strokeColor, int strokeWidth): Sets the style for the polygon (fill color, stroke color, and stroke width).
  • DrawMarker(): Draws markers on the map for each point added.
  • DrawPolygon(): Renders the polygon on the map using the specified points.

Utility and Calculation Methods

  • GetOrderedPointsYailList(): Returns an ordered list of points (YailList) for the drawn shape.
  • CalculateArea(): Calculates and returns the area of the drawn polygon.
  • calculateDistance(double lat1, double lon1, double lat2, double lon2): Computes the distance between two points, considering Earth's curvature.
  • CalculateTotalLineDistance(): Calculates the total distance of the line segments added.
  • ResetArea(YailList featuresToRemove): Resets the area points and removes specified features from the map.


  • ReportError(String errorMessage): Triggers an event to report an error with a custom message.

Explanation in Block Language Context

In the context of MIT App Inventor's block language:

  • Constructors are like initialization blocks that set up the extension.
  • Setters and Getters (SetLineMapDraw, GetLineMapDraw, etc.) are blocks that set or retrieve properties.
  • Drawing methods (AddPoint, DrawLineString, etc.) are action blocks that modify the map.
  • Utility functions (CalculateArea, calculateDistance, etc.) are similar to blocks that perform calculations or specific tasks.
  • Events (ReportError) work like event handlers in App Inventor, triggering when specific conditions are met.

This class essentially allows users to draw shapes on a map and calculate related data, like area and distances, using a familiar block-like approach.




Rename its to javafile.aia, upload here


Good work :+1: Keep it up :running_woman:

You may make it open source on your GitHub by making a repository. Otherwise you may rename it as .txt file.


I decided to share it on GitHub.


Good work :+1: Keep it up :smiling_face_with_three_hearts: @Passos_0213


Please share the apk link...

Great :+1:. But how can i show the area result in acre instead of m^2

One Acre is equal to 4046.85642199999983859016 Square Meters

So divide m^2 by 4047 to get acres.

I don't know extension is giving results in m^2 or in km^2 or in m ..?

What is this about..?

See the AIA example I developed.