Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scale bitmap before showing it on the map?

Tags:

android

bitmap

I want to set a icon for a marker, but it is too big so i want to scale it down.

MapFragment.this.map.addMarker(new MarkerOptions().position(new LatLng(lat, lng))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.guest_icon)));
like image 290
user3260664 Avatar asked Nov 02 '22 01:11

user3260664


1 Answers

This is a duplicate question. See: Change marker size in Google Maps API v2

Simply put, resize the bitmap prior to passing it to the MarkerOptions object you're creating, referencing the newly sized image. It's also worth noting that if it's a fairly large resource, you might want to do the resizing in an AsyncTask or another thread. See this thread for an example: Android , createScaledBitmap slow when creating multiple bitmaps

like image 149
Grant Amos Avatar answered Nov 09 '22 12:11

Grant Amos