Having Problems with Creating/Publishing and Consuming mobile maps for iOS

5223
14
Jump to solution
07-23-2012 05:55 AM
SpencerV
New Contributor III
Hi,

I'm working with a team that is seeking to develop a custom GIS app based off of the ArcGIS mobile API for iOS. We are using ArcGIS for Server 10.1 and are having some issues with retrieving maps that have been published. So far we have been creating very simple maps to test the publishing and retrieving experience on an iPad.

At this time we have a map published with a single feature layer that we want to be able to display and edit within ArcGIS mobile for iOS and eventually do the same in our custom application. While we were publishing this map we enabled "Feature Access" as well as "Mobile Data Access." Once the map is published we tried to move it to the mobile content directory on our server. We used a simple JSON syntax that we found in various tutorials. Below is a sample of the syntax that we used. Of course, we replaced the url with one linking back to our server.
{    "version":"1.1",    "baseMap":{       "baseMapLayers":[          {             "url":"https://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer"          }       ],       "title":"Topography"    },    "operationalLayers":[       {          "url":"http://OurServer/ArcGIS/rest/services/Gas_Stations/MapServer",          "visibility":true,          "opacity":0.75,          "title":"Environmental Sensitivity"       }          ] }


We are able to see the map in ArcGIS Mobile on the iPad and when we open it the base map that we are pulling from esri is displayed but no features are displayed. In addition, when we go to the content tab within the app there is no content listed. We then tried to pull the map into our custom app to have similar results. I was hoping that someone would be able to give a bit of guidance or help.

Thanks!
0 Kudos
14 Replies
SpencerV
New Contributor III
Yes it is the same URL. We believe it is a secure service. Our developers seem to be having issues generating tokens but even when they manually generate a token and use it in the program like
AGSCredential *cred = [[AGSCredential alloc] initWithToken:@"token_generated_manually" referer:@"http://ourserver"];
NSURL *url = [NSURL URLWithString:@"http://ourserver/arcgis/mobile/content/MobileWeb/Maps"];
layer = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL:url credential:cred];
lyr = [self.mapView addMapLayer:layer withName:@"Gas_Stations"];


They receive in the function failedLoadingLayerForLayerView for the baseLayer and in the failedLoadingLayerForLayerView for the second layer identical errors saying:

Error Domain=NSCocoaErrorDomain Code=500 "Unknown error occurred" UserInfo=0x86950a0 {NSLocalizedFailureReason=Unknown error occurred, NSURL=http://ourserver/arcgis/mobile/content/MobileWeb/Maps?f=json&token=token_generated_manually, NSLocalizedDescription=Unknown error occurred}
0 Kudos
NimeshJarecha
Esri Regular Contributor
I would like to clarify few things. There is a difference between web map and a layer. Web map is collection of layers. Please read web map documentation.

If you want to access your gas stations layer then your code should be,

AGSCredential *credential = [[[AGSCredential alloc] initWithUser:@"USERNAME" password:@"PASSWORD"]autorelease];
NSURL *url = [NSURL URLWithString:@"http://yourserver/ArcGIS/rest/services/Gas_Stations/MapServer"];
AGSDynamicMapServiceLayer *layer = [AGSDynamicMapServiceLayer dynamicMapServiceLayerWithURL:url credential:cred];
[self.mapView addMapLayer:layer withName:@"Gas_Stations"];

Let me know if this works...

Regards,
Nimesh
0 Kudos
SpencerV
New Contributor III
Is it necessary to use a web map when publishing a custom ArcGIS mobile app? When using the code you supplied we get the error:

Error Code=500 "The operation could not be completed."
0 Kudos
NimeshJarecha
Esri Regular Contributor
It is up to you whether you want to use web map or add layers to the map.

Is the layer URL is correct? same as you browsed in the Safari browser on the iPad? Are you using any user to access that service on the browser?

Regards,
Nimesh
0 Kudos
SpencerV
New Contributor III
It turns out that we were using a slightly incorrect URL in the code you provided. We were leaving out the sub folder that actually contained our MapServer. Once we corrected that it worked perfectly. Thank you for all of your help.

Regards,
Spencer
0 Kudos