Sub Process_Globals
Dim MapCenter As GeoPoint
Dim TileSource As String
Dim ZoomLevel As Int
End Sub
Sub Globals
Dim MapView1 As MapView
Dim Marker1 As Marker
Dim MarkersOverlay1 As MarkersOverlay
Dim TileSourceSpinner As Spinner
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.AddMenuItem("Change Marker1 Hotspot", "Menu")
' MapView initialized with no EventName as we'll not be listening for MapView events
MapView1.Initialize("")
Activity.AddView(MapView1, 0, 48dip, 100%x, 100%y-48dip)
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
' initialize the MarkersOverlay and add it to the MapView
' an EventName is required as we will listen for the two events that MarkersOverlay generates
MarkersOverlay1.Initialize(MapView1, "MarkersOverlay1")
MapView1.AddOverlay(MarkersOverlay1)
Dim Icon As BitmapDrawable
Icon.Initialize(LoadBitmap(File.DirAssets, "my_icon.png"))
Marker1.Initialize("Home sweet home", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi egestas suscipit convallis. Etiam pellentesque gravida est, quis luctus nunc commodo at. Nam et risus orci. Integer malesuada lorem dolor. Maecenas vestibulum cursus enim, tincidunt luctus libero placerat non. In vitae metus tellus, nec euismod nibh. Phasellus ut quam vitae justo sagittis auctor. Sed vel sapien dolor. Etiam ut sem id dolor iaculis ullamcorper. Aenean eget sem nibh, a tempor augue. Nulla interdum luctus molestie.", 52.75610, 0.39748, Icon)
Dim Markers As List
Markers.Initialize2(Array As Object(Marker1))
' add the List of Markers to the MarkersOverlay
MarkersOverlay1.AddMarkers(Markers)
If FirstTime Then
MapCenter=Marker1.GeoPoint
TileSource="Mapnik"
ZoomLevel=MapView1.GetMaxZoomLevel
End If
MapView1.Zoom=ZoomLevel
MapView1.SetCenter3(MapCenter)
TileSourceSpinner.Initialize("TileSourceSelect")
Activity.AddView(TileSourceSpinner, 0, 0, 100%x, 48dip)
TileSourceSpinner.AddAll(MapView1.GetTileSources)
TileSourceSpinner.Prompt="Select a TileSource"
TileSourceSpinner.SelectedIndex=TileSourceSpinner.IndexOf(TileSource)
TileSourceSelect_ItemClick(TileSourceSpinner.SelectedIndex, TileSourceSpinner.SelectedItem)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
MapCenter=MapView1.GetCenter
TileSource=MapView1.GetTileSource
ZoomLevel=MapView1.Zoom
End Sub
' two event listeners listen for the MarkersOverlay's two events
Sub MarkersOverlay1_Click(Title As String, Description As String, Point As GeoPoint)
Log("MarkersOverlay1_Click")
ToastMessageShow(Title&": "&Description, True)
End Sub
Sub MarkersOverlay1_LongClick(Title As String, Description As String, Point As GeoPoint)
Log("MarkersOverlay1_LongClick")
ToastMessageShow(Title&": Latitude="&Point.Latitude&", Longitude="&Point.Longitude, True)
' zoom the map in and center (with animation) on the LongClicked Marker
MapView1.Zoom=MapView1.GetMaxZoomLevel-1
MapView1.AnimateTo3(Point)
End Sub
Sub Menu_Click
Dim Action As String
Action=Sender
Select Action
Case "Change Marker1 Hotspot"
Marker1.MarkerHotspot=Marker1.HOTSPOT_PLACE_TOP_CENTER
MapView1.Invalidate
End Select
End Sub
Sub TileSourceSelect_ItemClick (Position As Int, Value As Object)
MapView1.SetTileSource(Value)
End Sub