Select to view content in your preferred language

ArcGISLocalDynamicMapServiceLayer Layers Ordered List

3732
4
Jump to solution
05-06-2013 12:42 PM
CarlosColón-Maldonado
Frequent Contributor
Greetings,

I'd like to be able to change the order that the layers of the packed map was originally in. For example, I packaged a map document that contained Layers layer1, layer2 and layer3 in that order, then later want to change the order of display to layer1, layer3 then layer2 through my Runtime app (on-the-fly). Is this possible?

Thanks in advanced.
0 Kudos
1 Solution

Accepted Solutions
CarlosColón-Maldonado
Frequent Contributor
I've discovered so far that the best way to re-order a list of layers in Runtime is by having them added as layers on the map from separate mpk files instead of sublayers or LayerInfo's off the same mpk. On the other hand, I can't seem to make multiple dynamic layers point to different mosaic datasets off the same gdb. Here's what I don't understand below (taken from the Add Rasters Sample):
        final String workspaceId = ""+count++; // an arbitrary unique string            // create a local map service and enable dynamic layers          LocalMapService localMapService = new LocalMapService(                  getPathSampleData() + "mpks" + FSP + "mpk_blank.mpk");          localMapService.setEnableDynamicLayers(true);            // get dynamic workspaces from service          WorkspaceInfoSet workspaceInfoSet = localMapService.getDynamicWorkspaces();            // create a workspace info via the static method according to data type          // e.g. raster folder connection          WorkspaceInfo workspaceInfo = WorkspaceInfo.CreateRasterFolderConnection(                  workspaceId, fileDir);          // also:          // --> WorkspaceInfo.CreateSDEConnection          // --> WorkspaceInfo.CreateShapefileFolderConnection          // --> WorkspaceInfo.CreateFileGeoDatabaseConnection            // set dynamic workspaces for our local map service          workspaceInfoSet.add(workspaceInfo);          localMapService.setDynamicWorkspaces(workspaceInfoSet);            // now start service...          localMapService.start();            // set up a local dynamic layer          final ArcGISDynamicMapServiceLayer localDynamicLayer = new ArcGISDynamicMapServiceLayer(                  localMapService.getUrlMapService());            // add the layer to the map          map.getLayers().add(localDynamicLayer);



1. We will not be using "WorkspaceInfo.CreateRasterFolderConnection", but "WorkspaceInfo.CreateFileGeoDatabaseConnection" which will point to this gdb, so how do I use it?

2. Once I "localMapService.setDynamicWorkspaces(workspaceInfoSet)", start the service and create an ArcGISDynamicMapServiceLayer using the service's Url, what will I get as layers? It's not intuitive to me what layers can be made out of a gdb connection.

About adding rasters using gpks (taken from the Viewshed sample):
            // create a Geoprocessor that points to the remote geoprocessing service.              // initialize the input parameters. refer to help link in the geoprocessing service URL.              Geoprocessor geoprocessor = new Geoprocessor(URL_GEOPROCESSING_SERVICE);              geoprocessor.setProcessSR(srMap);              geoprocessor.setOutSR(srMap);                List<GPParameter> gpInputParams = new ArrayList<GPParameter>();                GPFeatureRecordSetLayer gpInputViewshedPoint =                  new GPFeatureRecordSetLayer("Input_Observation_Point");              gpInputViewshedPoint.setSpatialReference(srMap);              gpInputViewshedPoint.addGraphic(viewshedPointGraphic);                GPLinearUnit gpInputViewshedDistance = new GPLinearUnit("Viewshed_Distance");              gpInputViewshedDistance.setUnits("esriMiles");              gpInputViewshedDistance.setDistance(inputValue);                gpInputParams.add(gpInputViewshedPoint);              gpInputParams.add(gpInputViewshedDistance); 


3. The "mpk_blank.mpk" would not be blank, but will have default rasters preloaded, and users will have the functionality to add or remove rasters, not as additional temporary layers, but to and from mosaic datasets via a gpk that knows the location of the gdb which the mpk files point to for its mosaic layers. The passed URL in the code points to the gpk file. How do I ensure the gpk points to the right/same mosaic dataset from the same gdb the mpk files point to so I can see the newly loaded rasters?

4. In my model, I have the parameters of mosaic dataset, raster type and workspace (folder containing the rasters). How do I pass it a mosaic dataset when it's contained in a gdb?

I'm sorry that this is long and, perhaps tedious. I'm literately stuck if I can't get pass this. Thanks in advanced.

View solution in original post

0 Kudos
4 Replies
EricBader
Honored Contributor
Yes, this is a good one. NOT an easy or elegant task.

What you MIGHT be able to try is this. (hold your nose!)


  1. Have an "empty" map package on hand, one that is a duplicate of the original, with all the layers removed.

  2. Collect the layer infos from the original ArcGISLocalDynamicMapServiceLayer

  3. Copy them in a different order into a new collection of layer infos

  4. Create a new ArcGISLocalDynamicMapServiceLayer using the empty map package you have on-hand

  5. Add the new layer infos collection (re-ordered) to the layer list of the new ArcGISLocalDynamicMapServiceLayer

  6. Add the new layer to the map


I wouldn't want to maintain something like this, but it may work anyway.

This is a good catch. It would be nice to have an easy way of reordering layers dynamically for local layers.

Of course, using online services, it is much easier. You can just create a new layer list and apply it again to the map in the order that you want.

I hope something helpful comes out of this response for you.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
Of course, using online services, it is much easier. You can just create a new layer list and apply it again to the map in the order that you want.


I could use ArcGISDynamicMapServiceLayer objects that points to a LocalMapService that is instantiated from the MPK with the mosaic layers, and then get the LayerInfo's from it to add to the blank MPK in different order, couldn't I? Wouldn't that be similar to what you describe? If so, could share some code? I'm having issues understanding how local map services work.

Thanks.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
I've discovered so far that the best way to re-order a list of layers in Runtime is by having them added as layers on the map from separate mpk files instead of sublayers or LayerInfo's off the same mpk. On the other hand, I can't seem to make multiple dynamic layers point to different mosaic datasets off the same gdb. Here's what I don't understand below (taken from the Add Rasters Sample):
        final String workspaceId = ""+count++; // an arbitrary unique string            // create a local map service and enable dynamic layers          LocalMapService localMapService = new LocalMapService(                  getPathSampleData() + "mpks" + FSP + "mpk_blank.mpk");          localMapService.setEnableDynamicLayers(true);            // get dynamic workspaces from service          WorkspaceInfoSet workspaceInfoSet = localMapService.getDynamicWorkspaces();            // create a workspace info via the static method according to data type          // e.g. raster folder connection          WorkspaceInfo workspaceInfo = WorkspaceInfo.CreateRasterFolderConnection(                  workspaceId, fileDir);          // also:          // --> WorkspaceInfo.CreateSDEConnection          // --> WorkspaceInfo.CreateShapefileFolderConnection          // --> WorkspaceInfo.CreateFileGeoDatabaseConnection            // set dynamic workspaces for our local map service          workspaceInfoSet.add(workspaceInfo);          localMapService.setDynamicWorkspaces(workspaceInfoSet);            // now start service...          localMapService.start();            // set up a local dynamic layer          final ArcGISDynamicMapServiceLayer localDynamicLayer = new ArcGISDynamicMapServiceLayer(                  localMapService.getUrlMapService());            // add the layer to the map          map.getLayers().add(localDynamicLayer);



1. We will not be using "WorkspaceInfo.CreateRasterFolderConnection", but "WorkspaceInfo.CreateFileGeoDatabaseConnection" which will point to this gdb, so how do I use it?

2. Once I "localMapService.setDynamicWorkspaces(workspaceInfoSet)", start the service and create an ArcGISDynamicMapServiceLayer using the service's Url, what will I get as layers? It's not intuitive to me what layers can be made out of a gdb connection.

About adding rasters using gpks (taken from the Viewshed sample):
            // create a Geoprocessor that points to the remote geoprocessing service.              // initialize the input parameters. refer to help link in the geoprocessing service URL.              Geoprocessor geoprocessor = new Geoprocessor(URL_GEOPROCESSING_SERVICE);              geoprocessor.setProcessSR(srMap);              geoprocessor.setOutSR(srMap);                List<GPParameter> gpInputParams = new ArrayList<GPParameter>();                GPFeatureRecordSetLayer gpInputViewshedPoint =                  new GPFeatureRecordSetLayer("Input_Observation_Point");              gpInputViewshedPoint.setSpatialReference(srMap);              gpInputViewshedPoint.addGraphic(viewshedPointGraphic);                GPLinearUnit gpInputViewshedDistance = new GPLinearUnit("Viewshed_Distance");              gpInputViewshedDistance.setUnits("esriMiles");              gpInputViewshedDistance.setDistance(inputValue);                gpInputParams.add(gpInputViewshedPoint);              gpInputParams.add(gpInputViewshedDistance); 


3. The "mpk_blank.mpk" would not be blank, but will have default rasters preloaded, and users will have the functionality to add or remove rasters, not as additional temporary layers, but to and from mosaic datasets via a gpk that knows the location of the gdb which the mpk files point to for its mosaic layers. The passed URL in the code points to the gpk file. How do I ensure the gpk points to the right/same mosaic dataset from the same gdb the mpk files point to so I can see the newly loaded rasters?

4. In my model, I have the parameters of mosaic dataset, raster type and workspace (folder containing the rasters). How do I pass it a mosaic dataset when it's contained in a gdb?

I'm sorry that this is long and, perhaps tedious. I'm literately stuck if I can't get pass this. Thanks in advanced.
0 Kudos
CarlosColón-Maldonado
Frequent Contributor
... the best way to re-order a list of layers in Runtime is by having them added as layers on the map from separate mpk files instead of sublayers or LayerInfo's off the same mpk. On the other hand, I can't seem to make multiple dynamic layers point to different mosaic datasets off the same gdb.


I made the choice of implementing the multiple dynamic map service layers in order to easily allow application users change the order and visibility of different raster types via a legend panel. I'm going to try the functionality of using dynamic workspaces mentioned on this post to make multiple dynamic layers point to different mosaic datasets off their own containing gdb.
0 Kudos