I made an Android app and want to add text above (or below) the marker. I found this link. How do I add text above the marker on Google Maps? but this is for the old google maps api. So I wonder if we can do the same with the new api?
I have ever tried to do this with this code:
Bitmap.Config conf = Bitmap.Config.ARGB_8888; Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.pin_favoris).copy(Bitmap.Config.ARGB_8888, true); Canvas canvas = new Canvas(bm); Paint paint = new Paint(); paint.setColor(Color.BLUE); paint.setTextSize(25); canvas.drawText("Favoris", 0, bm.getHeight(), paint); // paint defines the text color, stroke width, size BitmapDrawable draw = new BitmapDrawable(getResources(), bm); Bitmap drawBmp = draw.getBitmap(); // gMap.moveCamera(CameraUpdateFactory.newLatLngZoom(fakeMarker, 15)); gMap.addMarker(new MarkerOptions() .position(fakeMarker) .icon(BitmapDescriptorFactory.fromBitmap(drawBmp)) );
but text can only be displayed in a bitmap (no higher / lower)!
source share