Event when content of a layer is fully loaded

2549
4
Jump to solution
02-04-2016 11:26 PM
SvenPaulsen
New Contributor II

Hi all,

I'm new to the development of ArcGIS for JAVA. Currently, I've got an application which creates a map and loads 3 layers:

1. ArcGISTiledMapServiceLayer (World_Imagery)

2. ArcGISTiledMapServiceLayer (World_Transportation)

3. Some GPS-Points as Polylines (from a JSON-file)

When all the map content is fully loaded, I want to save the map as an image. At the moment this is done by writing a bufferedImage. Because in future the application should run automatically in backgorund, without showing the JFrame, I need some sort of event, signalizing when all content is loaded.

Is there any chance to get the correct moment, when all the work is done? Is there a more elegant way to save the map as an image?

Thanks in advance!

Sven

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
SvenPaulsen
New Contributor II

Hi all,

for all people encountering the same problem, there is an event ProgressEvent "which is fired by the map and indicates the draw progress of the Map's layer collection"

Therefore, saving the map as an image is possible, when the progress has reached 100 %:

jMap.addProgressEventListener(new ProgressEventListener()

{

     @Override

     public void progress(ProgressEvent event)

     {

          System.out.println(event.getProgress());

          if(event.getProgress() == 100)

          {

               SaveMap((JComponent) appWindow.getComponent(0));

          }

     }

});

@Adam: thanks for your help!

View solution in original post

Reply
0 Kudos
4 Replies
nita14
by
Regular Contributor

Hi Sven,

To save current map view as an image  I use exportMapImage method on JMap. Also, I add addMapEventListener to JMap and wait for mapReady event. This is pretty much my workflow.

Hope, you find it useful.

Adam

Reply
0 Kudos
SvenPaulsen
New Contributor II

Hi Adam,

thanks for your answer.

I tried your workflow, but unfortunately it seems that mapReady is fired before all the map content, i.e. the image tiles, is fully loaded. So, after calling the exportMapImage method the saved image only shows the GPS-points.

Do you know about any other event which is fired after the loading process?

Thanks!

Sven

Reply
0 Kudos
nita14
by
Regular Contributor

Hi Sven,

the only thing that comes to my mind is to add addLayerInitializeCompleteListener to all layers in your map. See the ArcGIS Runtime Samples - Layer Tree for sample usage.

Regards,

Adam

Reply
0 Kudos
SvenPaulsen
New Contributor II

Hi all,

for all people encountering the same problem, there is an event ProgressEvent "which is fired by the map and indicates the draw progress of the Map's layer collection"

Therefore, saving the map as an image is possible, when the progress has reached 100 %:

jMap.addProgressEventListener(new ProgressEventListener()

{

     @Override

     public void progress(ProgressEvent event)

     {

          System.out.println(event.getProgress());

          if(event.getProgress() == 100)

          {

               SaveMap((JComponent) appWindow.getComponent(0));

          }

     }

});

@Adam: thanks for your help!

View solution in original post

Reply
0 Kudos