Android Question Draw a Polygon on a Map

rafaelmotaquintana

Active Member
Licensed User
I have a google maps working in a test app.
I What I need is to draw a polygon on the map then calculate the area. I have searched with no luck.
I also have installed the navigation library. What I don't know is to mark the points in the maps then retrieve the coordinates for the calculation.
If there is any sample in the forum, it would be greatly appreciated is somebody send me the link.
Thanks
 

MarcoRome

Expert
Licensed User


B4X:
Sub MapFragment1_LongClick (mPoint As LatLng)
   ...
    gmap.AddMarker3(mPoint.Latitude,mPoint.Longitude, "MicroArea " &  Starter.numero_microarea,LoadBitmap(File.DirAssets,"flag50.png") ).InfoWindowShown = True
  ....

    lista_punta.Add(mPoint)
    If lista_punta.Size = 6 Then
        DrawPolygon(lista_punta)
    End If
End Sub

Sub MapFragment1_Click (Point As LatLng)
    .....
    Log(Point.Latitude)
    Log(Point.Longitude)
    .....
End Sub


Sub DrawPolygon (PointList As List)
    Dim GoogleMapsExtras1 As GoogleMapsExtras
    Dim polygonoptions1 As PolygonOptions
    polygonoptions1.Initialize
    polygonoptions1.FillColor=Colors.ARGB(150,255,255,0)
    polygonoptions1.AddPoints(PointList)
    polygonoptions1.StrokeColor=Colors.DarkGray
    polygonoptions1.StrokeWidth=3
    Dim pg As Polygon = GoogleMapsExtras1.AddPolygon(gmap, polygonoptions1)
End Sub
 
Top