Working with shapes
Google Maps for Android allows us to add custom shapes in our map application. The three ways supported are as follows:
Polyline
Polygon
Circle
Let's understand these methods now.
Polyline
Polyline is a set of points where line segments are drawn between consecutive points. For example, you can give a set of latitude, longitude coordinates as input, and lines are drawn connecting these points.
The following image is an example of a polyline that connects two points:
The Polyline
object consists of a set of latitude, longitude coordinates and it connects the points to each other.
Creating a polyline
A polyline can be created using a PolylineOptions
object. By calling the add()
method on the PolylineOptions
object, you can add latitude, longitude coordinates to the polyline. The add()
method takes the LatLng
object as a parameter. The polyline can be added to the Google map by calling the addPolyline()
method on the GoogleMap
object, which takes the PolylineOptions
object as a parameter...