I had the same problem trying to switch from v1 to v2. Finally, I used a marker, created a bitmap with text and used it as a marker icon.
First of all, you need to create a bitmap with text. Note: configure paintText with text properties (color, font, text, ...)
Rect boundsText = new Rect(); paintText.getTextBounds(strText, 0, strText.length(), boundsText); Bitmap.Config conf = Bitmap.Config.ARGB_8888; Bitmap bmpText = Bitmap.createBitmap(boundsText.width(), boundsText.height(), conf);
Then use Canvas to draw text. This is a little fix text madness with canvas reduction.
Canvas canvasText = new Canvas(bmpText); canvasText.drawText(strText, canvasText.getWidth() / 2, canvasText.getHeight(), paintText);
Finally, use Bitmap to create an icon in MarkerOption
MarkerOptions markerOptions = new MarkerOptions() .position(latlngMarker) .icon(BitmapDescriptorFactory.fromBitmap(bmpText)) .anchor(0.5f, 1);
Hope this helps you.
source share