如何在Android中修复Google

如何在Android中修复Google

本文介绍了如何在Android中修复Google Maps标记的自定义大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置标记大小.谁能告诉我?

How do I set the marker size. Can anyone tell me?

推荐答案

之所以发生这种情况,是因为您用作标记的图标的大小较大.因此,您可以先将其转换为Bitmap并更改其大小,然后再使用它位图作为自定义标记.例如,我已经制定了一种方法来调整位图的大小并返回调整后的位图.

It's happening because the icon you are using as a marker is bigger in size.So,You can first convert it into Bitmap and change its size and then use that bitmap in as a custom marker. For example I have made a method which resizes your bitmap and returns the resized bitmap.

public Bitmap resizeBitmap(String drawableName,int width, int height){
    Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(),getResources().getIdentifier(drawableName, "drawable", getPackageName()));
    return Bitmap.createScaledBitmap(imageBitmap, width, height, false);
}

然后在googleMap.addMarker()

googleMap.addMarker(new MarkerOptions()
            .title("New Marker").position(yourGivenPosition).icon(BitmapDescriptorFactory.fromBitmap(resizeBitmap("your drawable name",72,64))));

这篇关于如何在Android中修复Google Maps标记的自定义大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:16