I need to make a text annotation for a specific location (lat,lng) on google map (just text with no background, as street names in google map hybrid satellite view). The text should move accordingly when user rotates/moves the map. Is this possible?
You can create you own Marker-Icon dynamically and draw into it whatever you want, of course also text only.
public BitmapDescriptor createPureTextIcon(String text) {
Paint textPaint = new Paint(); // Adapt to your needs
float textWidth = textPaint.measureText(text);
float textHeight = textPaint.getTextSize();
int width = (int) (textWidth);
int height = (int) (textHeight);
Bitmap image = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Canvas canvas = new Canvas(image);
canvas.translate(0, height);
// For development only:
// Set a background in order to see the
// full size and positioning of the bitmap.
// Remove that for a fully transparent icon.
canvas.drawColor(Color.LTGRAY);
canvas.drawText(text, 0, 0, textPaint);
BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(image);
return icon;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With