I have an Android MapView in which i need to have a second layer of overlayed pins, over the one that the MapView already handles.
To accomplish this I have placed a FrameLayout over my MapView, and placed my pins as ImageViews in that Layout.
I have overridden the Draw() method of the ImageViews to update their position when the map moves (so that the pins move with it) like this:
public void draw(Canvas canvas) {
if(mCoordinates != null && mapView != null){
LayoutParams mParams = (LayoutParams)this.getLayoutParams();
mapView.getProjection().toPixels(mCoordinates, newPosition);
mParams.leftMargin = newPosition.x;
mParams.topMargin = newPosition.y;
}
super.draw(canvas);
}
The problem: views are updating too slowly, so when I move the map the pins seem to lagg behind it.
Any insights on approach or implementation welcome
In the end we just mad a method that would order the overlays every time so that the big overlays were always painted first and the small ones over those.