How to add mxd as layer to a MapView

4888
7
10-06-2015 08:16 AM
JohnDaues1
New Contributor

I have Android/Java code that adds layer to a MapView, calling a RESTful service, like so:

    mDynamicServiceLayer = new ArcGISDynamicMapServiceLayer(getResources().getString(R.string.some_url));

    mMapView.addLayer(mDynamicServiceLayer);

This works fine. I want to also add a layer that is an mxd file on the device

    <string name="mxd_file">file://storage/emulated/0/Download/mymap.mxd</string>

    mDynamicServiceLayer = new ArcGISDynamicMapServiceLayer(getResources().getString(R.string.mxd_file));

    mMapView.addLayer(mDynamicServiceLayer);

This throws the exception:

    java.lang.IllegalStateException: Scheme 'file' not registered.

I also tried:

    ArcGISLocalTiledLayer layer = new ArcGISLocalTiledLayer(getResources().getString(R.string.mxd_file));

    mMapView.addLayer(layer);

which gives this error:

    Failed to ensure directory: /storage/extSdCard/Android/data/arcgis_mmd_maplegends/cache

How do I do this?

0 Kudos
7 Replies
RebeccaStrauch__GISP
MVP Emeritus

At least to my knowledge, MXD's are not accessible directly.

You need to create a service from the MXD using ArcGIS Server (or ArcGIS Online or Portal). Then you should be able to load it in the same RESTful way as the other service. 

0 Kudos
JohnDaues1
New Contributor

Thanks for your reply, Rebecca. Perhaps you can steer me in the right direction. I have access to several RESTful services which provide layers of data. These would lay on top of an actual map. The map itself would be too large (ie take too long) to get over an internet connection and so I want the map to be on the device.

For this map, what would be the best form for it to have on the device, such that it and the RESTful layers could be added to a MapView?

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I don't use/know MapView, so can't help you there.  But if the data is from a service, there may be copy write or other restrictions on hosting the data on your own machine if it isn't "your" data.  Have you looked into http://www.arcgis.com/features/  yet?  That gives you the ability to access various ArcGIS and ArcGIS Online datasources, and possibly the ability to create your own services (need an account, although free accounts are available to do some tasks (see the link above).

If is data in-house (i.e. your agency has the ArcGIS Server) and you have access to the cache files direct, there are ways to access that with ArcGIS product, but I don't know about MapView.

0 Kudos
JohnDaues1
New Contributor

It is our data, we have an ArcGISServer, so no copyright issues. For a MapView, the layers can be a FeatureLayer, RasterLayer, KMLLayer, TiledLayer, DynamicLayer or GraphicsLayer. Can an mxd be converted to one of these?

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Yes, using ArcGIS Server.  There are steps to make sure your MXD is ready for publication. You don't mention what version of ArcGIS Desktop and/or ArcGIS Serve that you have, but here is About publishing services—Documentation (10.3 and 10.3.1) | ArcGIS for Server   You would have to work with you ArcGIS Server administrator so they can publish or give you permissions (depending on how you have it set up internally).  The MXD can them be published, at a minimum as a DynamicLayer.  TiledLayer mean the services has a cache....etc.

I see your link is to the layer Android API.  Have you looked at AppStudio for ArcGIS   That will let you create one app and deploy in native iOS, Android, and windows.

0 Kudos
JohnDaues1
New Contributor

It seems that it is best to use base maps created by esri (or google, or bing). Using the service at this url: 

http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer

I can get a base map like so:

mDynamicServiceLayer = new ArcGISDynamicMapServiceLayer(getResources().getString(R.string.world_street_map_url));

mMapView.addLayer(mDynamicServiceLayer);

So then the task is to have the base map saved to the device so it can be accessed off-line.

How is this done?

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

If you are going to need it for offline use, you may want to look at some of the other threads like

Re: ArcGIS Online Basemaps: Creating a Tile Cache for Offline Use

which also refers to those basemasps that might be available for offline use thru ArcGIS Online

http://www.arcgis.com/home/search.html?q=for%20export&t=content&focus=layers

I haven't downloaded any of these myself, so won't be of much help with details.

0 Kudos