I have been able to use \"MapActivity\" and \"ItemizedOverlay\" to draw overlays on google maps on android with Eclipse. But when the map is zooming in and out, the overlay does
After a bit of looking around, I came up with the following answer (I used code from this blog to do the resizing).
I overrode the same method used above, with some differences:
It ends up like this:
for(OverlayItem currentPoint:mOverlays){
geopoint =currentPoint.getPoint();
Point point = new Point();
projection.toPixels(geopoint, point);
BitmapDrawable bitDraw= ((BitmapDrawable)currentPoint.getMarker(0));
Drawable currentMarker = currentPoint.getMarker(0);
/*if (currentMarker!=null){
if (currentWidthRatio<.6f) {
currentWidthRatio = .6f;
}
else if (currentWidthRatio>1.5f) {
currentWidthRatio = 1.5f;
}
}*/
if (bitDraw!=null){
Bitmap bitmap = getResizedBitmap(bitDraw.getBitmap(),(int)(currentMarker.getIntrinsicHeight() * currentWidthRatio),
(int)(currentMarker.getIntrinsicWidth()*currentWidthRatio));
canvas.drawBitmap(bitmap,
point.x - bitmap.getHeight()/2,
point.y - bitmap.getWidth()/2, null);
}else{
Log.println(Log.DEBUG,"non-existent point", "");
}
}
Careful, though! The currentPoint.getMarker(0) method gets, as its name implies, the current marker's data. That means you have its original size, not the way it has grown (or shrunk) since. You have to have some method to:
The code I commented out handles the maximum and minimum resizing I want to allow (so the markers can be seen without overlapping / remain legible to the human eye).
I hope this helps!