title: Load Image into map Marker using android
body: <p>I am trying to add bitmap to google map marker icon.</p>
  
  <p>Below is my code to add image to marker icon. Application is crashing because of bitmap size</p>
  
  <p>Error :  java.lang.IllegalArgumentException: Textures with dimensions4096x8192 are larger than  the maximum supported size 4096x4096</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>BitmapFactory.Options options = new BitmapFactory.Options();
          options.inJustDecodeBounds = true;
          int imageHeight = options.outHeight;
          int imageWidth = options.outWidth;
          String imageType=options.outMimeType;
          if(imageWidth &gt; imageHeight) {
              options.inSampleSize = calculateInSampleSize(options,10,10);//if landscape
          } else{
              options.inSampleSize = calculateInSampleSize(options,10,10);//if portrait
          }
          options.inJustDecodeBounds = false;
  
  
          Bitmap  mapbitmap = BitmapFactory.decodeFile("/storage/emulated/0/Pictures/TAG_IMG_25.2571724_55.2994563.jpg", options);
  
  latLng=new LatLng(25.254376, 55.2973058);
  
  marker = googleMap.addMarker(new MarkerOptions()
              .position(latLng)
              .title(_title)
              .snippet("dubai")
              .icon(BitmapDescriptorFactory.fromBitmap(mapbitmap)));</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>public static int calculateInSampleSize(
              BitmapFactory.Options options, int reqWidth, int reqHeight) {
          // Raw height and width of image
          final int height = options.outHeight;
          final int width = options.outWidth;
          int inSampleSize = 1;
  
          if (height &gt; reqHeight || width &gt; reqWidth) {
  
              // Calculate ratios of height and width to requested height and width
              final int heightRatio = Math.round((float) height / (float) reqHeight);
              final int widthRatio = Math.round((float) width / (float) reqWidth);
  
              // Choose the smallest ratio as inSampleSize value, this will guarantee
              // a final image with both dimensions larger than or equal to the
              // requested height and width.
              inSampleSize = heightRatio &lt; widthRatio ? heightRatio : widthRatio;
          }
  
          return inSampleSize;
      }</code></pre>
  </div>
  </div>
  </p>