Sub Process_Globals
End Sub
Sub Globals
Dim MapFragment1 As MapFragment
Dim GoogleMap1 As GoogleMap
Dim MapPanel As Panel
Dim Polygon1 As Polygon
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
If MapFragment1.IsGooglePlayServicesAvailable = False Then
ToastMessageShow("Google Play services not available.", True)
Else
MapFragment1.Initialize("MapFragment1", MapPanel)
End If
End Sub
Sub MapFragment1_Ready
Log("MapFragment1_Ready")
GoogleMap1 = MapFragment1.GetMap
If GoogleMap1.IsInitialized = False Then
ToastMessageShow("Error initializing map.", True)
Else
GoogleMap1.MapType=GoogleMap1.MAP_TYPE_NORMAL
Dim GoogleMapsExtras1 As GoogleMapsExtras
Dim PolygonOptions1 As PolygonOptions
Dim PolygonCoords() As Double=Array As Double(52.7667, 0.3931, 52.7637, 0.3842, 52.7595, 0.3861, 52.7570, 0.3867, 52.7523, 0.3875, 52.7480, 0.3918, 52.7504, 0.3968, 52.7515, 0.4000, 52.7532, 0.4007, 52.7550, 0.4026, 52.7581, 0.4011, 52.7600, 0.3972, 52.7640, 0.4005, 52.7667, 0.3931)
Dim PolygonPoints As List=CoordsToLatLngList(PolygonCoords)
Dim HoleCoords() As Double=Array As Double(52.75844, 0.39227, 52.75926, 0.39546, 52.75983, 0.39477, 52.76045, 0.39540, 52.76041, 0.39583, 52.76287, 0.39767, 52.76332, 0.39598, 52.76084, 0.39420, 52.76062, 0.39496, 52.75994, 0.39453, 52.75995, 0.39401, 52.75928, 0.39173, 52.75844, 0.39227)
Dim HolePoints As List=CoordsToLatLngList(HoleCoords)
PolygonOptions1.Initialize
PolygonOptions1.AddHole(HolePoints)
PolygonOptions1.AddPoints(PolygonPoints) ' version 1.01 requires AddPolygonPoints to be used as the PolygonPoints property is now read-only
PolygonOptions1.FillColor=Colors.ARGB(128, 255, 0, 0)
' PolygonOptions1.PolygonPoints=PolygonPoints version 1.00 property PolygonPoints is now read-only
PolygonOptions1.StrokeColor=Colors.Black
PolygonOptions1.StrokeWidth=2
Polygon1=GoogleMapsExtras1.AddPolygon(GoogleMap1, PolygonOptions1)
Dim CameraPosition1 As CameraPosition
CameraPosition1.Initialize(52.75811, 0.3912, 13)
GoogleMap1.AnimateCamera(CameraPosition1)
End If
End Sub
Sub CoordsToLatLngList(PolygonCoords() As Double) As List
Dim PolygonCoordsCount As Int=PolygonCoords.Length
Dim LatLngList As List
LatLngList.Initialize
Dim i As Int
For i=0 To PolygonCoords.Length-2 Step 2
Dim LatLng1 As LatLng
LatLng1.Initialize(PolygonCoords(i), PolygonCoords(i+1))
LatLngList.Add(LatLng1)
Next
Return LatLngList
End Sub
Sub RemoveButton_Click
Polygon1.Remove
End Sub
Sub VisibilityButton_Click
Polygon1.Visible=Not(Polygon1.Visible)
End Sub