yes, it is possible (see the yellow polygon on the attached screenshot).
The mapsforge map library currently uses the 2D "Canvas" API from the
android.graphics package internally for all drawing operations (which is
actually an adapter for the Skia library, see:
http://code.google.com/p/skia/). If you want to add a polygon with one
or several holes (technically each "hole" is a polygon as well), all you
have to do is to set the GeoPoints of each polygon in the correct order
on your OverlayWay.
Example: the outer polygon is a triangle with nodes a1, b1 and c1. The
inner polygon is also a triangle with nodes a2, b2 and c2. In order to
draw the OverlayWay correctly the way node array must look like:
[a1, b1, c1, a1, a2, b2, c2, a2]
Each polygon must be closed, which means that the first and last
GeoPoint are equal. If more than one inner polygon is needed, just add
them in the same way to the array.
This was the theoretical part of the answer. Practically while i was
trying to generate the example screenshot, i found a little bug in the
WayOverlay class. Inner polygons could never make a hole in an outer
polygon due to that mistake. I already fixed it and committed everything
in revision r1127 (see
https://code.google.com/p/mapsforge/source/detail?r=1127). If you check
out the latest version from our repository, everything should work as i
just explained.
Please let me know in case the bug is not solved for you or further
problems arise.
Best regards,
Thilo
it was my mistake, i apologize. When i did the previous adjustments, i
must have been really tired. :-/
In order to draw multi-polygons correctly, the involved polygons must be
distinguishable. My first idea to put the polygon coordinates into one
big array was therefore stupid, as the borders between the different
polygons get completely lost.
Therefore i have now made a real change to the OverlayWay class which
solves the problem once and for all. The way data is now handled as a
multidimensional array. Each polygon is stored as a separate array. So
my example from the previous mail must now look like this:
[[a1, b1, c1, a1], [a2, b2, c2, a2]]
If only one polygon or a simple line should be drawn, just write:
[[a1, b1, c1]]
For this the API had to be modified a little bit. I marked all outdated
constructors and methods as deprecated, so that developers will notice
the change. Everything was committed with revision r1139. I tested the
implementation with your given multi-polygon coordinates and now
everything is displayed correctly, as the attached screenshot proves.
Thank you again for reporting the issue and please let me know in case
you find more bugs.
Best regards,
Thilo