首页 > 解决方案 > Google maps custom marker too large

问题描述

I am adding a custom marker to my map with code

marker =new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.bus)));

but it appears too large and covers the whole screen

enter image description here

how to solve this issue.

标签: javaandroidxmlgoogle-maps

解决方案


您可以以编程方式调整大小

解决方案1:

        int height = 100;
        int width = 100;
        BitmapDrawable bitmapdraw=(BitmapDrawable)getResources().getDrawable(R.drawable.bus);
        Bitmap b=bitmapdraw.getBitmap();
        Bitmap smallMarker = Bitmap.createScaledBitmap(b, width, height, false);

        MarkerOptions marker =   new MarkerOptions()
                .title("Your title")
                .icon(BitmapDescriptorFactory.fromBitmap(smallMarker));
        googleMap.addMarker(marker);

解决方案2:

很简单,您需要将图像更改为小尺寸。


推荐阅读