Select to view content in your preferred language

mapview.getMapDrawingCache() returns null

4678
20
12-30-2011 12:17 PM
SwatiGadey
Emerging Contributor
I am trying to create a bitmap image of the Map (MapView object) as follows:

Bitmap drawingCache = mapview.getDrawingCache(true);
Btimap bitmap = mapview.getDrawingMapCache(0, 0, mapview.getWidth(), mapview.getHeight());
Bitmap drawingCache = mapview.getDrawingCache(false);


This returns a null in my 'bitmap' object. What is the correct way of using mapview.getMapDrawingCache method for getting map image?
0 Kudos
20 Replies
SimonKlein
Regular Contributor
Can anybody reproduce this please, so it might get considered as a bug?

EDIT: The map is definitely loaded. I'm checking with MapView.isloaded() but on the frist run it still takes me now 103529 calls (on a rather complex webmap structure) of getDrawingMapCache to get a not null value. On the second run it takes only one call if the extent is not changed. The problem here is, that the map becomes really really slow after calling the getDrawingMapCache Method so many times. Some sort of memory leak somewhere I would guess.
0 Kudos
AndyGup
Esri Regular Contributor
Simon, I'm not familiar with this one, but I'm looking into whether it was a bug or not.

-Andy
0 Kudos
ArchanaAgarwal
Occasional Contributor
The problem is that when the bitmap is the entire map there is a lag in generating the bitmap.
If the bitmap is a smaller area the lag is unnoticeable.

This a bug we are fixing.

The code posted earlier if executed twice works without a problem.

Try using the code below, if you single tap on the map twice you will see the bitmap.


  map.setOnSingleTapListener(new OnSingleTapListener() {

      /**
       *
       */
      private static final long serialVersionUID = 1L;

      public void onSingleTap(float arg0, float arg1) {
       Polygon polygon = map.getExtent();
       Envelope env = new Envelope();
       polygon.queryEnvelope(env);
       Bitmap bitmap = map.getDrawingMapCache(arg0, arg1,
         100, 100));
//                                                        Bitmap bitmap = map.getDrawingMapCache(0, 0,
//         map.getWidth(), map.getHeight()));
       Log.d(TAG, "width = " + map.getWidth() + " ht = "
         + map.getHeight());
       ImageView img = new ImageView(HelloWorld.this);
       img.setImageBitmap(bitmap);
       map.addView(img);
      }
     });


Thanks
Archana
0 Kudos
AndyGup
Esri Regular Contributor
For reference: this problem has been logged under NIM081315.

-Andy
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
For reference: this problem has been logged under CR233566.

-Andy


To further expand on this:
I used the above code to generate an output image.  My map has a callout visible.  After looping +1000 times, I'm able to get the image out, BUT the map view displays a black box behind the callout.  Also, any other views that I have on top of my Map View (i.e. zoom contols) also have a black box behind them.

Here's a couple images..
outputimage = image output from export code
MapViewAfterExport = Map View after export.  Notice the black box behind the callout
MapViewAfterExport_closeCallout = Map View after export and callout is closed.  Notice the black box behind the zoom controls.

Any ideas??

[ATTACH=CONFIG]14812[/ATTACH][ATTACH=CONFIG]14813[/ATTACH][ATTACH=CONFIG]14814[/ATTACH]
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
Any update on NIM081315?
0 Kudos
AndyGup
Esri Regular Contributor
The system says  NIM081315 is resolved: http://support.esri.com/en/bugs/nimbus/TklNMDgxMzE1

Are you still having problems when using the latest SDK? If you are then please consider opening another support ticket. We may have missed something unique in your setup or configuration. Opening a ticket will help us track down and document any loose ends.

-Andy
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
I'm wondering if you provided the wrong NIM in a previous thread.  The Synopsis says: GraphicsLayer.createSymbolImages causes app to hang or respond slowly.  That's not the issue we are all experiencing here.
0 Kudos
deleted-user-ATjHIWsdQYmT
Deactivated User
However, I forgot to mention the bug does in fact seem to be fixed.

To expand - Any idea on how to include the callout as part of the image export?  It doesn't appear to be part of the MapView's drawing cache.
0 Kudos
AndyGup
Esri Regular Contributor
I saw that too right after I posted it. We're running this down now to make 100% sure.

-Andy
0 Kudos