Google 地图问题上的自定义标记

Custom Marker on Google Map Issue

在位图和 canvas 的帮助下,我的 Google 地图应用程序中使用了一个自定义标记。当我 运行 在具有 android 版本 5.1 或除 4.4 以外的任何其他设备上时,标记上的图像变得很好。

我确定这不是版本问题。但我很困惑,无法弄清楚我在哪里做错了。请帮我找到它。

自定义标记(位图)代码:

Bitmap.Config conf = Bitmap.Config.ARGB_8888;
            Bitmap bmp = Bitmap.createBitmap(128, 128, conf);
            Canvas canvas1 = new Canvas(bmp);


    canvas1.drawBitmap(BitmapFactory.decodeResource(getResources(),
                        R.drawable.map_markers_green), 0, 0, color);

                canvas1.drawText(String.valueOf(a).toUpperCase(), 56, 53, color);
                googleMap.addMarker(new MarkerOptions()
                        .icon(BitmapDescriptorFactory.fromBitmap(bmp))
                                // Specifies the anchor to be at a particular point in the marker image.
                        .anchor(0.5f, 1));

在设备上运行良好的标记图像:

即将在不同设备上剪切的相同标记图像:

试试这个代码

Bitmap.Config conf = Bitmap.Config.ARGB_8888;
Bitmap bmp = Bitmap.createBitmap(200, 50, conf); 
 Canvas canvas = new Canvas(bmp);
canvas.drawText("TEXT", 0, 50, paint); // paint defines the textcolor, stroke width, size
 mMap.addMarker(new MarkerOptions()
                            .position(clickedPosition)
                            //.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker2))
                            .icon(BitmapDescriptorFactory.fromBitmap(bmp))
                            .anchor(0.5f, 1)
                                );