Select to view content in your preferred language

Usages of ArcGISLocalDynamicMapServiceLayer, behaves different from the WPF API?

3852
2
Jump to solution
01-21-2013 11:16 AM
Jan-Tschada
Esri Contributor
Would someone be so kind and explain the usage of the implementation of ArcGISLocalDynamicMapServiceLayer?

If you want to use dynamic workspaces with the ArcGIS Runtime SDK for Java 10.1.1 you have to use the ArcGISDynamicMapServiceLayer implementation e.g. for adding shapefiles or local geodatabases. Trying to use an instance of ArcGISLocalDynamicMapServiceLayer will fail. No exception is be thrown, instead the LayerStatus is ERRORED and Layer::getInitializationError returns "WARNING: The filename, directory name, or volume label syntax is incorrect" after the layer initialize complete event was fired. ArcGISLocalDynamicMapServiceLayer extends directly from ArcGISDynamicMapServiceLayer, but behaves different using dynamic workspaces.

Is it correct that ArcGISLocalDynamicMapServiceLayer is only used for dynamic layers directly pointing to an existing map package?

When I was using ArcGIS Runtime SDK for WPF 10.1 using an instance of ArcGISLocalDynamicMapServiceLayer for dynamic workspaces worked as expected. But you had to specify a LocalMapServer instance not the corresponding URL.
arcGisLocalDynamicMapServiceLayer = new ArcGISLocalDynamicMapServiceLayer(localMapService)


Works:
 private List<ArcGISDynamicMapServiceLayer> createLocalDynamicLayers(LocalMapService localMapService, WorkspaceInfoSet dynamicWorkspaces) {
  List<ArcGISDynamicMapServiceLayer> localLayerList = new ArrayList<>(dynamicWorkspaces.size());
  
  for (final WorkspaceInfo dynamicWorkspace : dynamicWorkspaces) {
   ArcGISDynamicMapServiceLayer mapServiceLayer = new ArcGISDynamicMapServiceLayer(localMapService.getUrlMapService());
   mapServiceLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {

    @Override
    public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
     logger.info(bundle.getString("LocalDataLoader.info.localDynamicLayerInitialized"));
     
     ArcGISDynamicMapServiceLayer localDynamicLayer = (ArcGISDynamicMapServiceLayer) e.getLayer();
     LayerStatus status = localDynamicLayer.getStatus();
     if (LayerStatus.INITIALIZED != status) {
      logger.severe(String.format(bundle.getString("LocalDataLoader.error.localDynamicLayerUninitialized"), localDynamicLayer.getUrl()));
      
      String initializationError = localDynamicLayer.getInitializationError();
      logger.warning(initializationError);
      return;
     }


Fails:
 private List<ArcGISDynamicMapServiceLayer> createLocalDynamicLayers(LocalMapService localMapService, WorkspaceInfoSet dynamicWorkspaces) {
  List<ArcGISDynamicMapServiceLayer> localLayerList = new ArrayList<>(dynamicWorkspaces.size());
  
  for (final WorkspaceInfo dynamicWorkspace : dynamicWorkspaces) {
   ArcGISDynamicMapServiceLayer mapServiceLayer = new ArcGISLocalDynamicMapServiceLayer(localMapService.getUrlMapService());
   mapServiceLayer.addLayerInitializeCompleteListener(new LayerInitializeCompleteListener() {

    @Override
    public void layerInitializeComplete(LayerInitializeCompleteEvent e) {
     logger.info(bundle.getString("LocalDataLoader.info.localDynamicLayerInitialized"));
     
     ArcGISDynamicMapServiceLayer localDynamicLayer = (ArcGISDynamicMapServiceLayer) e.getLayer();
     LayerStatus status = localDynamicLayer.getStatus();
     if (LayerStatus.INITIALIZED != status) {
      logger.severe(String.format(bundle.getString("LocalDataLoader.error.localDynamicLayerUninitialized"), localDynamicLayer.getUrl()));
      
      String initializationError = localDynamicLayer.getInitializationError();
      logger.warning(initializationError);
      return;
     }


Thanks in advance
Product Manager
Developers and Location Services
Germany and Switzerland
0 Kudos
1 Solution

Accepted Solutions
MarkBaird
Esri Regular Contributor
Hi J.T.

I can't see exactly what you are trying to do but let me try to give you some information.

Firstly lets look at the difference between ArcGISDynamicMapServiceLayer and ArcGISLocalDynamicMapServiceLayer:

- The ArcGISDynamicMapServiceLayer is a layer which is for consuming online data where the datasource might be coming from your ArcGIS Server or ArcGIS Online.  The constructor takes the URL for the service (a rest end point).  This is data you use in a network connected environment.

- An ArcGISLocalDynamicMapServiceLayer layer is for consuming local data where you might not have network connectivity.  The constuctor for this class takes a path to your .mpk file.  The .mpk file is a map package which you will have published from ArcGIS Desktop.

Beyond the above differences they are much the same once added to the map.  The above explanation applied for both Java SE and WPF.

Now in your code samples you are working with  Dynamic Workspaces.  These can be used for altering the content of a local map package on the fly.  For example, you might have an .mpk to which you want to add a shapefile.  If this is what you are trying to do I would take a look at the Sample Application which comes with the API.  We have a code sample which shows you how to add a shapefile.  This was added to the sample application at the 10.1.1 release.

Does this help?

Regards

Mark

View solution in original post

0 Kudos
2 Replies
MarkBaird
Esri Regular Contributor
Hi J.T.

I can't see exactly what you are trying to do but let me try to give you some information.

Firstly lets look at the difference between ArcGISDynamicMapServiceLayer and ArcGISLocalDynamicMapServiceLayer:

- The ArcGISDynamicMapServiceLayer is a layer which is for consuming online data where the datasource might be coming from your ArcGIS Server or ArcGIS Online.  The constructor takes the URL for the service (a rest end point).  This is data you use in a network connected environment.

- An ArcGISLocalDynamicMapServiceLayer layer is for consuming local data where you might not have network connectivity.  The constuctor for this class takes a path to your .mpk file.  The .mpk file is a map package which you will have published from ArcGIS Desktop.

Beyond the above differences they are much the same once added to the map.  The above explanation applied for both Java SE and WPF.

Now in your code samples you are working with  Dynamic Workspaces.  These can be used for altering the content of a local map package on the fly.  For example, you might have an .mpk to which you want to add a shapefile.  If this is what you are trying to do I would take a look at the Sample Application which comes with the API.  We have a code sample which shows you how to add a shapefile.  This was added to the sample application at the 10.1.1 release.

Does this help?

Regards

Mark
0 Kudos
Jan-Tschada
Esri Contributor
Thank you for clarification.

I was just confused because the WPF API allows creating an ArcGISLocalDynamicMapServiceLayer passing an instance of a local map service to the constructor. It would be nice if the Java API uses stronger types e.g. MapPackage(java.io.File path) for paths to mpk's and URL for REST end points.
Product Manager
Developers and Location Services
Germany and Switzerland
0 Kudos