giroxasmnl
giroxasmnl

Reputation: 131

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()))
            );

Upvotes: 0

Views: 886

Answers (2)

AniV
AniV

Reputation: 4037

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));
    

Upvotes: 1

josedlujan
josedlujan

Reputation: 5600

Resize the Bitmap before adding it as a Marker.

Upvotes: 0

Related Questions