java - 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
how to solve this issue.
解决方案
您可以以编程方式调整大小
解决方案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:
很简单,您需要将图像更改为小尺寸。
推荐阅读
- python - 在 Conda 环境中使用通过 apt-get 安装的 OpenCV
- python - 如何在 matploitlib 中呈现尼泊尔语文本
- python - 为 iplot 方程添加轴标题
- python - 我想将每一行保存为列表
- mysql - 如何让 SQL 获取以“P”开头并后跟“11”数字的 ID
- docker - Docker Pull Access Denied for Repository 不存在或需要登录
- git - 将多个文件版本导入 git 的任何工具?
- python - 使用 Azure 函数 HTTP 触发器的 mTLS?
- python - 计算之前出现的单词数
- javascript - 在 WebStorm 中绑定到 [attr.for] 和 [id] 时缺少关联的标签错误