android google map marker,How to add values in google map v2 marker android?

For a full free drawing of the marker icon the code may look like the following.

In this case only the text is the content of the marker. But you can draw anything into the canvas. Just make sure to adapt the size.

public BitmapDescriptor getTextMarker(String text) {

Paint paint = new Paint();

/* Set text size, color etc. as needed */

paint.setTextSize(24);

int width = (int)paint.measureText(text);

int height = (int)paint.getTextSize();

paint.setTextAlign(Align.CENTER);

// Create a transparent bitmap as big as you need

Bitmap image = Bitmap.createBitmap(width, height, Config.ARGB_8888);

Canvas canvas = new Canvas(image);

// During development the following helps to see the full

// drawing area:

canvas.drawColor(0x50A0A0A0);

// Start drawing into the canvas

canvas.translate(width / 2f, height);

canvas.drawText(text, 0, 0, paint);

BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(image);

return icon;

}

Then use this method when building the marker options:

mMap.addMarker(new MarkerOptions()

.position(new LatLng(lati, longi))

.icon(getTextMarker("some text"));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值