base map not loading with VPN connection

2284
3
Jump to solution
01-20-2016 12:31 AM
QKunZhu
New Contributor II

I successfully opened base map link with user name and password from safari, but this sample app does not work after connect to VPN. The VPN I am using is Cisco AnyConnect. I cannot test without VPN otherwise I am not able to access the server.

iOS9.2, server url is a https.

The code is simple:

- (void)viewDidLoad {
AGSCredential* cred = [[AGSCredential alloc] initWithUser:MAP_UNAME password:MAP_PWD];
   
_baseMapLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:[NSURL URLWithString:BASE_MAP_URL_STRING] credential:cred];
[self.mapView insertMapLayer:_baseMapLayer withName:@"Base" atIndex:0];
   
self.mapView.layerDelegate = self;
}

- (void)mapViewDidLoad:(AGSMapView *)mapView
{
    if (mapView.loaded)
        NSLog(@"map loaded");
    else
        NSLog(@"map not loaded");
}

None of the log from mapViewDidLoad get called..

I also have problem to debug because it's a enterprise provision file. Is there any place for me to log something to check?

Any help..

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Try implementing the AGSLayerDelegate protocol and checking the layerDidLoad: and layer:didFailToLoadWithError: methods. Something like:

@interface MyClass () <..., AGSLayerDelegate> // Include AGSLayerDelegate in your protocols list

- (void)viewDidLoad {  
   AGSCredential* cred = [[AGSCredential alloc] initWithUser:MAP_UNAME password:MAP_PWD];  
     
   _baseMapLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:[NSURL URLWithString:BASE_MAP_URL_STRING] credential:cred];  
   _baseMapLayer.delegate = self;

   [self.mapView insertMapLayer:_baseMapLayer withName:@"Base" atIndex:0];       
   self.mapView.layerDelegate = self;  
}

- (void)layerDidLoad:(AGSLayer *)layer {
    NSLog(@"Layer %@ loaded OK", layer.name);
}

- (void)layer:(AGSLayer *)layer didFailToLoadWithError:(NSError *)error {
    NSLog(@"Failed to load layer: %@", error.localizedDescription);
}

That should give you a log of why the layer is failing to load (which will prevent the map loading).

View solution in original post

0 Kudos
3 Replies
Nicholas-Furness
Esri Regular Contributor

Try implementing the AGSLayerDelegate protocol and checking the layerDidLoad: and layer:didFailToLoadWithError: methods. Something like:

@interface MyClass () <..., AGSLayerDelegate> // Include AGSLayerDelegate in your protocols list

- (void)viewDidLoad {  
   AGSCredential* cred = [[AGSCredential alloc] initWithUser:MAP_UNAME password:MAP_PWD];  
     
   _baseMapLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:[NSURL URLWithString:BASE_MAP_URL_STRING] credential:cred];  
   _baseMapLayer.delegate = self;

   [self.mapView insertMapLayer:_baseMapLayer withName:@"Base" atIndex:0];       
   self.mapView.layerDelegate = self;  
}

- (void)layerDidLoad:(AGSLayer *)layer {
    NSLog(@"Layer %@ loaded OK", layer.name);
}

- (void)layer:(AGSLayer *)layer didFailToLoadWithError:(NSError *)error {
    NSLog(@"Failed to load layer: %@", error.localizedDescription);
}

That should give you a log of why the layer is failing to load (which will prevent the map loading).

View solution in original post

0 Kudos
QKunZhu
New Contributor II

Thanks Nicholas.

That helps and the problem is I need to import certificate to bundle. Then need to add the followings:

// 1. import certificate
[AGSCredential importCertificateData:cerData password:nil overwrite:NO error:&error];

// 2. trust base map url connection
[[NSURLConnection ags_trustedHosts] addObject:[mapURL host]];

Now everything works fine.

Nicholas-Furness
Esri Regular Contributor

Excellent. Thanks for letting me know!

Nick.

0 Kudos