I can't show web map using AGSWebMap

2081
4
02-10-2012 09:44 PM
haiwang
New Contributor
- (void) webMapDidLoad:(AGSWebMap*) webMap {
    //webmap data was retrieved successfully
    NSLog(@"load successfully");
    [self.webmap openIntoMapView:self.mapView];
    [self.mapView setNeedsDisplay];
}

- (void) webMap:(AGSWebMap *)webMap didFailToLoadWithError:(NSError *)error {
    //webmap data was not retrieved
    //alert the user
    NSLog(@"Error while loading webmap: %@",[error localizedDescription]);
}

-(void)didOpenWebMap:(AGSWebMap*)webMap intoMapView:(AGSMapView*)mapView{
    //web map finished opening
    NSLog(@"delegate method: didOpenWebMap:(AGSWebMap*)webMap intoMapView:(AGSMapView*)mapView");
}

-(void)didLoadLayer:(AGSLayer*)layer{
    //layer in web map loaded properly
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *mapId = @"49c555e22cdf480181153f35d18f8863";//1d105a71e3eb499383e4b7556f0bbc34
    self.webmap = [[AGSWebMap alloc] initWithItemId:mapId credential:nil];
    self.webmap.delegate = self;
    
}

-(void)didFailToLoadLayer:(NSString*)layerTitle url:(NSURL*)url baseLayer:(BOOL)baseLayer withError:(NSError*)error
{
    NSLog(@"Error while loading layer: %@",[error localizedDescription]);
}

- (void)viewDidUnload
{
    [self setMapView:nil];
    self.webmap = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}



console output:


GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Thu Nov  3 21:59:02 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 1092.
2012-02-11 15:38:32.540 HelloArcGis[1092:f203] load successfully
2012-02-11 15:38:32.544 HelloArcGis[1092:f203] delegate method: didOpenWebMap:(AGSWebMap*)webMap intoMapView:(AGSMapView*)mapView
0 Kudos
4 Replies
haiwang
New Contributor
I have retained webMap
@property (retain, nonatomic) IBOutlet AGSMapView *mapView;
@property (retain, nonatomic) AGSWebMap *webmap;
0 Kudos
haiwang
New Contributor
Nobody can help ?
0 Kudos
PaulLohr
Occasional Contributor III
Did you make the connection between the property and Interface Builder object?
0 Kudos
Nicholas-Furness
Esri Regular Contributor
Hi,

I think the problem is that your WebMap has as its basemap layer a Bing Maps layer, for which you need to specify your Bing Maps key.

If you add this delegate method, and return your key, you should be good to go:

-(NSString*)bingAppId{
    return @"YOUR BING MAPS KEY";
}


This page tells you how to go about getting a key. See also the sample delegate in the Concepts document.

Hope this helps. Let us know how you get on.

Cheers,

Nick.
0 Kudos