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);
Failed to decode image. The provided image must be a Bitmap.
But in log I got :com.google.android.gms.maps.model.BitmapDescriptor@58e0ee6
:com.google.android.gms.maps.model.GroundOverlayOptions@1ea9c27
Also I converted jpg image to bmp, after failing to convert it here
Help please.
See https://stackoverflow.com/a/45564994/2914140 for vector drawables (SVG).
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With