google maps - How to draw unique labels on overlayitem of mapview in android -


here screenshot of i'm trying achieve

enter image description here

i add unique label (like numbers) each overlayitem of map. have done basic part of adding overlayitems , showing them on map. stuck long time

you can add overlayitem different markers on same itemizedoverlay using function:

overlayitem.setmarker(drawable); 

for work, need set bounds on drawable:

drawable icon1 = getresources().getdrawable(r.drawable.icon1); drawable icon2 = getresources().getdrawable(r.drawable.icon2); icon1.setbounds(0, 0, icon1.getintrinsicwidth(), icon1.getintrinsicheight()); icon2.setbounds(0, 0, icon2.getintrinsicwidth(), icon2.getintrinsicheight()); overlayitem item1 = new overlayitem(new point(48858290, 2294450),      "tour eiffel", "la tour eiffel"); overlayitem item2 = new overlayitem(new point(48873830, 2294800),      "arc de triomphe", "l'arc de triomphe");                         item1.setmarker(icon1); item2.setmarker(icon2); 

you need bitmaps max number of markers. faster dynamically draw text on bitmaps. it's mobile phone, processors not fast. if prefer draw text on bitmap anyway, ii's easy, can this:

//get reference on imageview  imageview iv = (imageview)findviewbyid(r.id.myimage);  // load marker image bitmap myrefbitmap = bitmapfactory.decoderesource(getresources(),      r.drawable.icon);  // create mutable bitmap same size marker image bitmap mywrittenbitmap = bitmap.createbitmap(myrefbitmap.getwidth(),      myrefbitmap.getheight(), bitmap.config.argb_4444);  // create canvas on draw , paint write text. canvas canvas = new canvas(mywrittenbitmap); paint txtpaint = new paint(); txtpaint.setcolor(color.red); txtpaint.settextsize(12); txtpaint.setflags(paint.anti_alias_flag); txtpaint.settypeface(typeface.default_bold);  //draw ref bitmap text on our canvas canvas.drawbitmap(myrefbitmap, 0, 0, null); canvas.drawtext("droid", 5, 15, txtpaint);  // set new written bitmap imageview iv.setimagebitmap(mywrittenbitmap); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -