0

In my app i need to make a big map. I used this code to load image of map to the Google map as a ground overlay.

GroundOverlayOptions newarkMap = new GroundOverlayOptions() 
            .position(new LatLng(0, 0), 27000000f, 12735849f)  
            .image(BitmapDescriptorFactory.fromResource(R.drawable.map3));
googleMap.addGroundOverlay(newarkMap);

However, after several entries to the fragment with the map, i get OOM exception.

java.lang.OutOfMemoryError: Failed to allocate a 134217740 byte allocation with 16777216 free bytes and 37MB until OOM

So, is there any way to load large images to the Google map?

Vitaly Kalenik
  • 410
  • 4
  • 12

2 Answers2

1

Don't load whole image - use TileProvider like in this answer of Alex Vasilkov

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
0

The bitmap you are trying to use is evidently very large. Check out this link from Google that will explain the how and why to load bitmaps in a more efficient manner : https://developer.android.com/topic/performance/graphics/load-bitmap.html

Devsil
  • 598
  • 3
  • 16