How can we achieve a map marker icon with vector asset file, the way google shows it like this, programatically:
Update:
m
If someone who is looking for in kotlin here is the method for you :
private fun bitmapDescriptorFromVector(context: Context, vectorResId:Int):BitmapDescriptor {
var vectorDrawable = ContextCompat.getDrawable(context, vectorResId);
vectorDrawable!!.setBounds(0, 0, vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight());
var bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
var canvas = Canvas(bitmap);
vectorDrawable.draw(canvas);
return BitmapDescriptorFactory.fromBitmap(bitmap);
}
above method will convert you vector icon to bitmapdescritor
map.addMarker(new MarkerOptions()
.position(latLng)
.icon(bitmapDescriptorFromVector(getActivity(), R.drawable.your_vector_asset))
.title(title)
and this one for setting marker for your map thanks for Leo Droidcoder from his answer only i have converted it to kotlin