I have a strange problem that I don't really know how to attack so I'm wondering if someone has had a similar problem before.
I override the draw(Canvas canvas, MapView mapView, boolean shadow) method in an ItemizedOverlay subclass to draw some paths, text etc. between the items. The first thing I do in the override is call super.draw with all these parameters. When I start the app, the lines that I draw in my override are where they are supposed to be, but the actual OverlayItems that the super.draw draws are way off. The interesting thing is that as I move the map towards the upper left corner (coords 0,0) the OverlayItems get nearer and nearer to the place where I expect them to be (in fact, they appear to match perfectly when I get the first item to point (0,0)). As I move the map so that the OverlayItems get further from the (0,0) point, they linearly get further from their geolocation.
In case nobody has faced this problem before and it isn't something obvious, I'll try to make a minimal example that still has this behavior and post it here. The actual code is relatively large so I'd like to avoid that much work if someone has any idea what might be the problem.
edit: an additional piece of information that might be helpful... my draw method looks like this:
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
if (!shadow) {
// code for drawing the lines etc.
// on the canvas (uses mapView.getProjection())
}
}
The custom part of the overlay doesn't have a shadow layer (I've used the same logic when extending Overlay without trouble). The shadow layer that gets drawn for the OverlayItems by super.draw is actually halfway between the Drawable and the expected geolocation for each particular item.
Here are tree screenshots from the avd to better illustrate what is happening. The four red pins should be on the red line above them and actually move towards the line as I slide the map towards the top left. The two pins and the line between them is drawn in my custom override, super.draw draws the four shadows and the four extra red pins.
Since this is my first post and I can't post more than one link, I put all three screenshots on the same jpg.
screenshot