简体   繁体   中英

Android - Resize Icon Map

I'm currently making an app that displays the photos on the map using an icon. However it displays very big photos. How can you actually resize an icon in google maps?

Here is my code for adding a marker:

mMap.addMarker(new MarkerOptions().position(new LatLng(Latitude, Longitude)).title("Picture")
                                              .snippet("picture" + i)
                                              .flat(true)
                                              .icon(BitmapDescriptorFactory.fromPath(listFile[i].getAbsolutePath()))
            );

Need to perform just two steps:

  • Know the height and width of the bitmap before loading this using this code:

     BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(getResources(), R.id.myimage, options); int imageHeight = options.outHeight; int imageWidth = options.outWidth; 
  • Change it to the size you want and pass it as icon in Your maps as markers:

     Bitmap b = BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length) profileImage.setImageBitmap(Bitmap.createScaledBitmap(b, 150, 80, false)); 

调整位图的大小,然后再将其添加为标记。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM