Sub Process_Globals
Dim MapCenter As GeoPoint
Dim TileSource As String
Dim ZoomLevel As Int
Dim MapTouchEnabled As Boolean
' create some variables to save the MyLocationOverlay state
Dim CompassEnabled, FollowLocationEnabled, MyLocationEnabled As Boolean
End Sub
Sub Globals
Dim MapView1 As MapView
Dim MinimapOverlay1 As MinimapOverlay
Dim ScaleBarOverlay1 As ScaleBarOverlay
Dim TouchEventGrabber As Panel
' create the MyLocationOverlay
Dim MyLocationOverlay1 As MyLocationOverlay
End Sub
Sub Activity_Create(FirstTime As Boolean)
' update the MenuItems
' Activity.AddMenuItem("Toggle Compass", "MenuItemSelect")
' Activity.AddMenuItem("Toggle MyLocation", "MenuItemSelect")
Activity.AddMenuItem("Toggle FollowLocation", "MenuItemSelect")
Activity.AddMenuItem("Toggle MapTouchEnabled", "MenuItemSelect")
' MapView initialized with no EventName as we'll not be listening for MapView events
MapView1.Initialize("")
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
' initialize and add the MyLocationOverlay to the MapView, an EventName is used as we'll be listening for all three events that this overlay generates
MyLocationOverlay1.Initialize(MapView1, "MyLocationOverlay1")
MyLocationOverlay1.MyLocationEnabled = True
MyLocationOverlay1.FollowLocationEnabled = True
MapView1.AddOverlay(MyLocationOverlay1)
If FirstTime Then
MapTouchEnabled=True
TileSource="Mapnik"
ZoomLevel=14
' set the default values for the new variables
CompassEnabled=MyLocationOverlay1.CompassEnabled
FollowLocationEnabled=MyLocationOverlay1.FollowLocationEnabled
MyLocationEnabled=MyLocationOverlay1.MyLocationEnabled
Else
' restore the MyLocationOverlay state
MyLocationOverlay1.CompassEnabled=CompassEnabled
End If
MapView1.Zoom=ZoomLevel
ScaleBarOverlay1.Initialize(MapView1)
MapView1.AddOverlay(ScaleBarOverlay1)
TouchEventGrabber.Initialize("TouchEventGrabber")
If MapTouchEnabled Then
Activity.AddView(TouchEventGrabber, 0, 0, 0, 0)
Else
Activity.AddView(TouchEventGrabber, 0, 0, 100%x, 100%y)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
MapCenter=MapView1.GetCenter
TileSource=MapView1.GetTileSource
ZoomLevel=MapView1.Zoom
' save the MyLocationOverlay state
CompassEnabled=MyLocationOverlay1.CompassEnabled
FollowLocationEnabled=MyLocationOverlay1.FollowLocationEnabled
MyLocationEnabled=MyLocationOverlay1.MyLocationEnabled
' disable MyLocationOverlay compass and GPS listening
MyLocationOverlay1.CompassEnabled=False
MyLocationOverlay1.MyLocationEnabled=False
End Sub
Sub MenuItemSelect_Click
Dim Id As String
Id=Sender
Select Id
Case "Toggle MapTouchEnabled"
MapTouchEnabled=Not(MapTouchEnabled)
If MapTouchEnabled Then
TouchEventGrabber.Width=0
TouchEventGrabber.Height=0
Else
TouchEventGrabber.Width=100%x
TouchEventGrabber.Height=100%y
End If
Case "Toggle FollowLocation"
MyLocationOverlay1.FollowLocationEnabled=Not(MyLocationOverlay1.FollowLocationEnabled)
End Select
End Sub
Sub TouchEventGrabber_Touch (Action As Int, X As Float, Y As Float)
' do nothing
End Sub