Search code examples
overlayosmdroid

Osmdroid, Custom Overlay Drawing


For an Android App I have created a custom overlay here, to display various items of game data on the map.

In general the overlay works fine and smoothly!

However there is one geometrical constellation which is not working as expected: Some objects within the overlay are not bound to geocoordinates, but to current user location. Now it happens, that Osmdroid is selectively redrawing the screen. When the screen is not focussed to user location, the user location bound stuff is not updated correctly: New stuff gets only drawn in some selective rectangle, old stuff isn't deleted outside that rectangle.

So far I failed to find a mechanism to communicate the required redraw of an overlay to the basic Osmdroid system? I.e. to invalidate the surroundings of the current user location? Any hint, clue or pointer?


Solution

  • By studying the sample code I realized they really consider it the overlay responsibility to issue appropriate invalidate calls to the map component to ensure their own optical integrity.

    I am still struggling with the coordinates to do the right invalidate(left, top, right, buttom) calls cause my updates actually happen on location changes and it is unclear to me if the screen pixel of the map to be invalidated need to get measured relative to the old location or the new one. This is actually a timing question.

    However taking the CPU byte and issuing postInvalidate() just looks as intended and it is unclear how much performance is really lost.