-
Notifications
You must be signed in to change notification settings - Fork 22
Basemaps
nixta edited this page Jan 18, 2013
·
11 revisions
##Overview A single method is added to AGSMapView (see AGSMapView+EQSBasemaps.h):
@property (nonatomic, assign) EQSBasemapType basemap;
EQSBasemapType is an enumeration including the following values (from EQSBasemapTypeEnum.h):
EQSBasemapTypeStreet
EQSBasemapTypeSatellite
EQSBasemapTypeHybrid
EQSBasemapTypeCanvas
EQSBasemapTypeNationalGeographic
EQSBasemapTypeTopographic
EQSBasemapTypeOpenStreetMap
Set the basemap of the current AGSMapView with a simple call:
self.mapView.basemap = EQSBasemapTypeStreet;
##Notifications You can register to be told about a successful basemap change on an AGSMapView by listening on the default NSNotificationCenter for kEQSNotification_BasemapDidChange (see EQSBasemapsNotifications.h).
For example:
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.basemap = EQSBasemapTypeStreet;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(basemapDidChange:)
name:kEQSNotification_BasemapDidChange
object:self.mapView];
}
Convenience methods are added to NSNotification to easily get at useful information (again, see EQSBasemapsNotifications.h):
@property (nonatomic, readonly) AGSPortalItem *basemapPortalItem;
@property (nonatomic, readonly) EQSBasemapType basemapType;
For example:
- (void)basemapDidChange:(NSNotification *)notification
{
EQSBasemapType basemapType = notification.basemapType;
// Do something with the new basemap type...
AGSPortalItem *pi = notification.basemapPortalItem;
NSLog(@"Basemap is now: %@", pi.title);
// Ooooh. Look. We're already using core AGS objects!
// Now go learn what an AGSPortalItem is!!
}