Image of the marker too big Google Maps

0

I'm customizing a map marker but when loading the map it shows me in a very exaggerated size and not in the size of the marker, try to try placing a vector, but it showed me the following error.

 com.google.maps.api.android.lib6.common.apiexception.b: Failed to decode image. The provided image must be a Bitmap.

I want the marker to fit me the following way and in the default size.

    
asked by Carlos 09.08.2018 в 00:54
source

1 answer

-1

To solve the detail of the exception that is sending you, when using the image in the method of new MarkerOptions () icon, it would be:

.icon(bitmapDescriptorFromVector(this, R.drawable.marker));

private BitmapDescriptor bitmapDescriptorFromVector(Context context, @DrawableRes  int vectorDrawableResourceId) {
     Drawable background = ContextCompat.getDrawable(context, R.drawable.ic_map_pin_filled_blue_48dp);
     background.setBounds(0, 0, background.getIntrinsicWidth(), background.getIntrinsicHeight());
     Drawable vectorDrawable = ContextCompat.getDrawable(context, vectorDrawableResourceId);
     vectorDrawable.setBounds(40, 20,vectorDrawable.getIntrinsicWidth() + 40, vectorDrawable.getIntrinsicHeight() + 20);
     Bitmap bitmap = 
     Bitmap.createBitmap(background.getIntrinsicWidth(), background.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
     Canvas canvas = new Canvas(bitmap);
     background.draw(canvas);
     vectorDrawable.draw(canvas);
     return BitmapDescriptorFactory.fromBitmap(bitmap);
}

I attached the reference link where you answer your question Stackoverflow League

    
answered by 09.08.2018 / 01:45
source