I am having trouble with changing googlemap marker on the googlemap.
Neither this method works
MarkerOptions markerOptions = new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(MarkerManager.getBitmapFromVectorDrawable(context, R.drawable.marker_no_issues)));
marker.setIcon(markerOptions.getIcon());
nor this
marker.setIcon(BitmapDescriptorFactory.fromBitmap(MarkerManager.getBitmapFromVectorDrawable(context, R.drawable.marker_no_issues)));
Method getBitmapFromVectorDrawable:
public static Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = (DrawableCompat.wrap(drawable)).mutate();
}
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
}
What i am doing wrong? Why i cant change marker icon with setIcon method. I have also tried raw .png files and i know that vector to bitmap works well.