Using OSMDroid 4.1 and have a TouchOverLay to add GeoPoints to a PathOverLay.
Both OverLays are added to a MapView, named MapView1.
This works fine and the GeoPoints are added OK. Problem it doesn't show directly in the MapView.
Moving the MapView refreshes the image and makes the path show with the new GeoPoint. Tried all sorts of constructions to fix this, Sleep(X), DoEvents (I know is deprecated and caused indeed a crash), waiting loops and also constructions with ResumableSub, but all with no good result.
In the end I came up with this and that seems to work:
This seems to work fine as it doens't give a flicker and updates the appearance of the MapView.
Is there anything wrong with this approach? Are there better ways to handle this?
RBS
Both OverLays are added to a MapView, named MapView1.
B4X:
Sub TouchOverLay1_Click(GeoPoint1 As OSMDroid_GeoPoint) As Boolean
AddAreaPoint(GeoPoint1)
Return(False)
End Sub
Sub AddAreaPoint(GeoPoint1 As OSMDroid_GeoPoint)
'as there seems no way to get these back from the PathOverLay!
PathOverLay1Points.Add(GeoPoint1)
PathOverlay1.AddPoint(GeoPoint1)
End Sub
This works fine and the GeoPoints are added OK. Problem it doesn't show directly in the MapView.
Moving the MapView refreshes the image and makes the path show with the new GeoPoint. Tried all sorts of constructions to fix this, Sleep(X), DoEvents (I know is deprecated and caused indeed a crash), waiting loops and also constructions with ResumableSub, but all with no good result.
In the end I came up with this and that seems to work:
B4X:
Sub RefreshView(oView As View)
oView.Visible = False
oView.Visible = True
End Sub
Sub AddAreaPoint(GeoPoint1 As OSMDroid_GeoPoint)
'as there seems no way to get these back from the PathOverLay!
PathOverLay1Points.Add(GeoPoint1)
PathOverlay1.AddPoint(GeoPoint1)
RefreshView(MapView1)
End Sub
This seems to work fine as it doens't give a flicker and updates the appearance of the MapView.
Is there anything wrong with this approach? Are there better ways to handle this?
RBS