BitmapDescriptor bmpD = BitmapDescriptorFactory.fromResource(R.raw.podval);
Log.d("myLog", ":" + bmpD);
GroundOverlayOptions newarkMap = new GroundOverlayOptions()
.image(bmpD)
.position(sydney, 8600f, 6500f);
Log.d("myLog", ":" + newarkMap);
GroundOverlay imageOverlay = mMap.addGroundOverlay(newarkMap);
无法解码图像。提供的图像必须是位图。
但是在日志中我得到了:com.google.android.gms.maps.model.BitmapDescriptor@58e0ee6
:com.google.android.gms.maps.model.GroundOverlayOptions@1ea9c27
此外,我将jpg图像转换为bmp,之后无法将其转换为
请帮助。
答案 0 :(得分:1)
将图像放在可绘制文件夹中,而不是放在原始文件夹中。还要确保资源是有效的图像文件。
答案 1 :(得分:0)
有关矢量可绘制对象(SVG),请参见https://stackoverflow.com/a/45564994/2914140。
private BitmapDescriptor bitmapDescriptorFromVector(Context context, @DrawableRes int vectorResId) {
Drawable vectorDrawable = ContextCompat.getDrawable(context, vectorResId);
vectorDrawable.setBounds(0, 0, vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight());
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.draw(canvas);
return BitmapDescriptorFactory.fromBitmap(bitmap);
}