kiddykooly / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Overlay.onDraw() + Picture.beginRecording() impossible #206

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've found it impossible to use the Picture class in the Overlay onDraw method.
In many cases it can improve performance quite a bit to draw a single picture 
object instead of doing all canvas operations in sequence.

While it is of course possible to draw a picture on the canvas the coordinates 
make it impossible to use the feature.

Picture.beginRecording requires (WIDTH and HEIGHT).
But the canvas has virtual coordinates ranging from 
x=-127,y=-127 (zooomed out) up to x=2419227,y=-10183099  (zoomed in)

Almost all coordinates resolve to an X or an Y coordinate with a negative 
number.
The only coordinates that I found reachable using the Picture method are close 
to Africa, those coordinates translate into positive numbers.

Maybe there is some solution, I've been talking to various people and trying to 
find one for quite a while and was not successful.
The negative pixel coordinates make it impossible to draw using a Picture 
class. (and probably several other classes will fail the same way)

Original issue reported on code.google.com by nol...@gmail.com on 16 Apr 2011 at 1:06

GoogleCodeExporter commented 8 years ago
Use pMapView.getProkjection().getScreenRect() to get the current coordinates 
that are on the screen. If you want to draw something at 50,50 the code would be

int x = screenRect.top + 50
int y = screenRect.left + 50

Original comment by kurtzm...@gmail.com on 10 May 2011 at 6:10

GoogleCodeExporter commented 8 years ago

The issue is when drawing on the MAP not on the screen, so you need 
map-relative coordinates which are incompatible with Picture because of the 
huge range and offsets.
I guess it's just impossible by design, I solved it by creating an image 
instead of a Picture and using matrix transformations to place it on the map.

Original comment by nol...@gmail.com on 11 May 2011 at 8:24

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 15 May 2011 at 11:32