Draw a Line between two coordinates in a TMapView (Delphi FMX)


I have a TMapView on my Form. The TMapView works fine so far but I want to add the possibility to draw a Line between two coordinates on the TMapView. How can I do that?
I tried the following which does not work in any way:
A,B: TMapCoordinate;
AB: TMapPolylineDescriptor;
//MapView1.Canvas.DrawLine(A,B,50); //doesnt work
// AB.Points:=[A,B]; //doesnt work too
//MapView1.AddPolyline(AB); //doesnt work too

I guess the canvas thing wont work as I want as I think it just connects points on the TMapView as a Bitmap and not on the map itself. Please suggest me how I can draw a Line between two coordinates on the map (if that is possible)
I use Delphi 10.3.3 Community Edition and try to compile it on my android 10 phone.
I found this SO Link where the Polyline is used in Objective-C for MapKit on iPhone. I guess I have to do the same thing in delphi, but I have no idea how to do this.. but I saw Polyline draws a maps route between two points. Thats good to know too, but I just want my Line drawn and no maps route suggestion from Google.
if I use this code:
if MapView1.Canvas.BeginScene then
Canvas.Fill.Color := $FF111111 + random($FFFFFF);
Canvas.Fill.Kind := TBrushKind.Solid;
Canvas.FillRect(RectF(random(300), random(300), random(300), random(300)),
0, [], 1);

it works and draws a colored Rectangle somwhere in some color, but is disappears immediately after showing up.. maybe thats why my Lines arent visible too. Maybe they’re painted but overpainted immediately. I Dont know much about canvas of my TMapView or Canvas in general, but after painting the "square" it dissappears and I guess those Lines are just disappearing too. Can I somehow make those selfpainted canvas changes permanent until I overpaint them by myself?

Comments are closed.