Reputation: 93
I want to tint an icon for my google maps. Here is my code -
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.my_location));
How can I tint to the color I want? Currently the drawable is in green color.
Upvotes: 0
Views: 607
Reputation: 58934
You can do this easily, you can set your image drawable which is placed in your drawable folder. This is not tint but this is best solution.
itmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.yourdrawable)
MarkerOptions markerOptions = new MarkerOptions().position(latLng)
.title("Current Location")
.snippet("Thinking of finding some thing...")
.icon(icon);
mMarker = googleMap.addMarker(markerOptions);
Update
You can use this to change color of your bitmap
private Bitmap changeBitmapColor(Bitmap sourceBitmap, int color) {
Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0,
sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1);
Paint p = new Paint();
ColorFilter filter = new LightingColorFilter(color, 1);
p.setColorFilter(filter);
Canvas canvas = new Canvas(resultBitmap);
canvas.drawBitmap(resultBitmap, 0, 0, p);
return resultBitmap;
}
for using bitmap BitmapDescriptorFactory.fromBitmap
, let me know if this solves your issue.
Upvotes: 1