Hi,
I have the following issue. When I display a point on the map and go to this location it does not work. When I use the debugger it works well? I suppose that it has to do with timing or I am doing something not correct below my code of the test activity.
The problem is when the SingleMap is true and display one point.
I have the following issue. When I display a point on the map and go to this location it does not work. When I use the debugger it works well? I suppose that it has to do with timing or I am doing something not correct below my code of the test activity.
The problem is when the SingleMap is true and display one point.
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SingleMap As Boolean
Dim selectedItem As JD
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim bar As BarView
Dim mp As MapView
Dim MarkersOverlay1 As MarkersOverlay
Dim MapIcon As BitmapDrawable
Dim Markers As List
Dim MarkersFocusOverlay1 As MarkersFocusOverlay
Dim MinimapOverlay1 As MinimapOverlay
Dim ovlLocation As MyLocationOverlay
End Sub
Sub Activity_Create(FirstTime As Boolean)
MapIcon.Initialize(LoadBitmap(File.DirAssets, "map-pin.png"))
bar.Initialize(Me,"Main")
bar.headerVisible=False
bar.AddToActivity(Activity,0,0dip,100%x,100%y)
mp.Initialize("")
Activity.AddView(mp,0,0,100%x,100%y-bar.btnBarHeight)
mp.SetMultiTouchEnabled(True)
MarkersOverlay1.Initialize(mp, "MarkersOverlay1")
mp.AddOverlay(MarkersOverlay1)
'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
ovlLocation.Initialize(mp,"mylocation")
mp.AddOverlay(ovlLocation)
' ensure that the MinimapOverlay is the LAST overlay added to the MapView
MinimapOverlay1.Initialize(mp)
mp.AddOverlay(MinimapOverlay1)
If SingleMap Then
DisplayPoint
Else
mp.Zoom=10
mp.SetCenter(Update.loc.latitude,Update.loc.Longitude)
mp.AnimateTo2(Update.loc)
DisplayPoints
End If
End Sub
Sub DisplayPoints
If Not (Markers.IsInitialized) Then Markers.Initialize
Markers.Clear
MarkersOverlay1.RemoveMarkers
For Each e In Main.items
Dim item As JD = e
Dim m As Marker
m.Initialize(item.GetTitle, item.GetCompany,item.GetLatitude,item.GetLongitude,MapIcon)
Markers.Add(m)
Next
MarkersOverlay1.AddMarkers(Markers)
'mp.FitMapToBoundingBox(MarkersOverlay1.GetBoundingBox)
End Sub
Sub DisplayPoint
If Not (Markers.IsInitialized) Then Markers.Initialize
Markers.Clear
MarkersOverlay1.RemoveMarkers
Dim m As Marker
m.Initialize(selectedItem.GetTitle, selectedItem.GetCompany,selectedItem.GetLatitude,selectedItem.GetLongitude,MapIcon)
Markers.Add(m)
MarkersOverlay1.AddMarkers(Markers)
mp.AnimateTo(selectedItem.GetLatitude,selectedItem.GetLongitude)
mp.Zoom=16
End Sub
Last edited: