有没有一种方法可以将字符串值放入 Google Maps API 2.0 上的 Marker
图标中?
喜欢这张图片
简单来说。有点像这样:
map.addMarker(new MarkerOptions()
.position(POSITION)
.title("Your title")
.icon(HERE PUT MY VAR STRING)
);
最佳答案
您可以使用您的文字自定义图标:
Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(80, 80, conf);
Canvas canvas = new Canvas(bmp);
// paint defines the text color, stroke width and size
Paint color = new Paint();
color.setTextSize(35);
color.setColor(Color.BLACK);
// modify canvas
canvas.drawText(YOUR_STRING, 30, 40, color);
// add marker to Map
mMap.addMarker(new MarkerOptions().position(USER_POSITION)
.icon(BitmapDescriptorFactory.fromBitmap(bmp)));
关于标记图标内的 Android Google Maps API 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37626354/