title: Android Google Map Drawing Text on Multiple Overlays with Custom Marker
body: <p>I need to draw text on a custom marker which are quite a lot in number. But the problem is that when I draw the text in the Overridden on draw, all the overlay items text appears to be in one layer above the markers and does not seem synched when the map is zoomed in or zoomed out. Previously I was calling the populate when each item was added and this was working fine but it was too slow. Any help?</p>
  
  <p>In my custom class that extends from ItemizedOverlay, the constructor is as follows, where I set the custom marker:</p>
  
  <pre><code>    public HotelMapFilterOverlay(Drawable defaultMarker, final Context con) {
      super(boundCenterBottom(defaultMarker));
      this.marker = defaultMarker;
      this.con = con;
  }
  </code></pre>
  
  <p>and the overridden draw method is as follows:</p>
  
  <pre><code>    @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
       super.draw(canvas, mapView, shadow);
       Bitmap bmp = ((BitmapDrawable) marker).getBitmap();
  
       Paint textPaint = new Paint();
       textPaint.setColor(Color.WHITE);
       textPaint.setTextSize(16f);
       textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, 1));
       textPaint.setStyle(Paint.Style.FILL);
  
       Point screenPts = new Point();
  
       float bmpWidth = bmp.getWidth();
       float bmpHeight = bmp.getHeight();
  
       float left;
       float top;
  
       int total = mOverlayItems.size();
       for (int index = 0; index &lt; total; index++) {
  
      gp = mOverlayItems.get(index).getPoint();
      mapView.getProjection().toPixels(gp, screenPts);
  
      left = screenPts.x - (bmpWidth / 2);
      top = screenPts.y - bmpHeight;
  
      // draw text
      this.title = mOverlayItems.get(index).getTitle();
      canvas.drawText(this.title, left + 8, top + 30,textPaint);          
      }
  }
  </code></pre>
  
  <p>and I calling the populate only once to make this efficient like </p>
  
  <pre><code>public void callPopulate(){
     populate();
  }
  </code></pre>