With this code, whenever the screen is pressed the map view disappears. I don't want the map view to disappear. I want it to either: 'not react to user interaction what so ever' or 'users can move the view around but when the location is changed then it snaps back to the new location'. I'm sure its a simple fix but it has stumped me for quite a while :L Thanks in advance! (By the way OSMDroid, fantastic mapview library. I'm loving it! learning java so hopefully in a bit I'll be able to contribute some libraries) Here is the code:
B4X:
Sub Process_Globals
Dim MapCenter As GeoPoint
Dim TileSource As String
Dim ZoomLevel As Int
' 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
' 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")
' MapView initialized with no EventName as we'll not be listening for MapView events
MapView1.Initialize("")
Activity.AddView(MapView1, 0, 0, 100%x, 100%y)
MapView1.SetMultiTouchEnabled(True)
MapView1.SetZoomEnabled(True)
' 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")
MapView1.AddOverlay(MyLocationOverlay1)
If FirstTime Then
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
MyLocationOverlay1.MyLocationEnabled = True
MyLocationOverlay1.FollowLocationEnabled = True
ScaleBarOverlay1.Initialize(MapView1)
MapView1.AddOverlay(ScaleBarOverlay1)
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
Last edited: