Issue
My Code is as follows. Essentially, I am trying to replace each marker with my custom marker, namely my drawable beer_full.
This overridden draw function in my custom overlay is doing the job perfectly, BUT it leaves the default icon there too. So my markers are appearing on my map as my custom marker on top of the default marker.
Anyone know how I stop the default marker showing?
Cheers
@Override
public void draw(Canvas canvas, MapView mapview, boolean shadow) {
// TODO Auto-generated method stub
super.draw(canvas, mapview, shadow);
if(!shadow)
{
for (int ctr = 0; ctr < myOverlays.size(); ctr++)
{
GeoPoint in = myOverlays.get(ctr).getPoint();
//Toast.makeText(mapview.getContext(), ctr, Toast.LENGTH_SHORT).show();
Point out = new Point();
mapview.getProjection().toPixels(in, out);
Bitmap bm = BitmapFactory.decodeResource(mapview.getResources(),
R.drawable.beer_full);
canvas.drawBitmap(bm,
out.x - bm.getWidth()/2, //shift the bitmap center
out.y - bm.getHeight()/2, //shift the bitmap center
null);
}
}
}
Solution
Remove the line super.draw(canvas, mapview, shadow);. You are basically drawing the default icon (by calling the default implementation of the draw method), and then drawing your custom icon over it.
Answered By - Marcelo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.