I am developing an application that has a few custom overlays on a MapView – representing vessels. When selecting a vessel, I am showing its previous positions on the map, again with custom overlay items, and I would like to connect them with a line.
Some relevant problems I saw here were solved by overriding the Draw method, and by hard-coding the GeoPoints’ coordinates in the Draw method. That does not help me at all, since I have many points from different vessels, and cannot hard-code them all into Draw.
Is there a simple way to just draw a line between the GeoPoints inside the for loop used to display the custom overlays??
Thanks you in advance.
Use the
Projectionfrom theMapViewin order to convert GeoPoints to “screen” points. After that you can usePathto draw the line that you want. The first point should be specified withpath.moveTo(x, y)and the rest withpath.lineTo(x, y). At the end you callcanvas.drawPath(path)and you are done.Below is a code from my draw() method that draws a polygon around a set of points. Note that you do not have to use
path.close()as I did on my code.