android - google map android - 无法从 BitmapDescriptorFactory.fromAsset 设置 map 图标

标签 android kotlin flutter

我正在尝试使用以 .bmp 文件形式提供的标记图像来使用自定义标记。我正在使用 Flutter 构建跨平台应用程序,这是 Android 的原生代码。图片来自 flutter 项目中 pubspec.yaml 中的资源。

  marker = map
       .addMarker(MarkerOptions()
       .position(annotation.coordinate)
       .title(annotation.title)
       .icon(BitmapDescriptorFactory.fromAsset("lib/green_circle.bmp")))

我收到上面代码的错误消息:

com.google.maps.api.android.lib6.common.apiexception.b: Failed to decode image. The provided image must be a Bitmap.

我检查了图像,它是 bmp enter image description here

最佳答案

它处理图像的方式似乎有问题。它确实接受 png、jpg 和 bmp,因为我已经对所有这些格式进行了测试,但我对这些格式(png 和 bmp)的某些文件也有同样的问题。

我所做的是在另一个图像编辑器上打开一些文件,覆盖这些文件,并且成功了。奇怪的是,这些文件是来自 Adob​​e Photoshop 的普通 png 图标,但它们不起作用。

如果您有任何问题或疑问,可以尝试使用其他来源的文件进行调试,或者编辑它并再次保存。

关于android - google map android - 无法从 BitmapDescriptorFactory.fromAsset 设置 map 图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48899176/

相关文章:

android - 我可以在 contentObserver 中创建 Alert 和 Toast 吗?

navigation - Flutter 中带有导航栏的永久 View

android - 为什么“文本对齐”无法正常使用?

android - Firebase 消息传递错误(仅限 Android)- 新推送通知的致命异常

android - Nutiteq 3D SDK 上的动画标记

android - 带有头像、文本和图标的列表的 Material 设计建议

Android-SD卡

kotlin - 为什么Kotlin中的groupBy通用形式还不够?

Kotlin 测试 : How to test for a specific type like: "is y instance of X"

android - 未找到参数 #1 的改造注释