I am using KML to show specific zones on the map which you can click on and get some info of. The application has to work offline so I'm using KML files locally.
My problem right now is when my overlay showing the KML zones is enabled, the app's overall speed is reduced and after a certain zoom level the polygons becomes too big to render.
I would like to get some general tips to make my implementation of KML less ressource-heavy and other useful info concerning OSMBonusPack with KML.
(Example: I noted that OSMDroid renders the zones texture even when out of my sight, and I have no idea how to prevent such things.)
Trying to optimize the display of numerous graphical objects is a vast question. Trying to be generic, there are 2 classical solutions in this area:
1) At low zoom levels, we have many objects to display. But as we are far from them, we can try to simplify them. Typical solutions: markers clustering, polyline/polygon simplification.
=> markers clustering is available in OBP, but not used by default in KML to overlay conversion.
=> a polyline/polygon simplification is available with DouglasPeuckerReducer.
=> There is no dynamic simplification according to zoom level. If you think it may bring improvement in your context, this is not a big deal to implement it by sub-classing polygon/polyline and adapt the draw method.
2) At high zoom levels, we are close to some objects. But many objects are completely outside the view. Typical solution: quick check with bounding boxes, to eliminate objects or even groups of objects (assuming they are properly grouped).
=> This is not implemented currently in osmdroid/OSMBonusPack. Implementation could be done through a revised FolderOverlay, maintaining a bounding box attribute, and with a draw method checking this bounding box against mapview bounding box. This would be efficient only if users use this folder for spatial groups of objects (objects spatially close) - not for logical groups of objects.