The iOS client library is a native library written in Objective-C and can be incorporated into any iOS app for the iPod Touch, iPhone, and iPad. It is built upon ArcGIS's iOS client libraries, which provides a MapView and asynchronous tile loading, coupled with a custom TWMS data loader.
The library comes with a sample client to display TWMS maps and includes basic manipulations such as presenting data from arbitrary TWMS server, selecting a time-value, and map layer reordering.
Requirements
- iOS 5.0+
- ArcGIS iOS Client Library 2.2.1+ (Download here)
Usage
To use the library, create an AGSMapView object, either programmatically or linked from Interface Builder, and use the following code snippet as an example.
TWMSTiledWebMapService *earthTwms = [[TWMSTiledWebMapService alloc] initWithUrl:[NSURL URLWithString:@"http://gibs.earthdata.nasa.gov/twms/epsg4326/best/twms.cgi?request=GetTileService"]];
TWMSTiledMap *aquaMap = [[earthTwms tiledMaps] valueForKey:@"MODIS AQUA tileset"];
TWMSTiledMapLayer *aquaMapLayer = [[TWMSTiledMapLayer alloc] initWithTiledMap:aquaMap];
[agsMapView addMapLayer:aquaMapLayer withName:[aquaMap name]];
Screenshots
There are no images attached to this page. |
Additional Documentation
The ArcGIS iOS documentation can be obtained here.
The standard iOS documentation can be viewed here.
The iOS library defines 3 classes that are used to load TWMS data:
TWMSTiledWebMapService: Instantiated for each TWMS endpoint.
TWMSTiledMap: Represents an individual map layer in the TWMS.
TWMSTiledMapLayer: A subclass of ArcGIS's map layer to show TWMS data.
TWMSTiledWebMapService
Properties
name: The name of the TWMS as defined in the GetTiledService request.
title: The title of the TWMS as defined in the GetTiledService request.
abstract: The abstract of the TWMS as defined in the GetTiledService request.
tiledMaps: A dictionary where the keys are the name of each map layer and values are the TWMSTiledMap instances.
Methods
(id)initWithUrl:(NSURL*)url: Loads the TWMS data given by the url to instantiate this class.
(NSArray*)listAllTiledMapsByName: Returns a sorted list of map layer names.
(void)setTiledMapKeyValue:(NSString*)value forTiledMapKey:(NSString*)key: Assigns variable keys for all TiledMaps in the TWMS server.
(NSDictionary*)tiledMapKeyValues: Returns a dictionary of all the keys used in all TiledMaps and the value its currently set to.
TWMSTiledMap Properties
name: The name of the layer as defined in the GetTiledService request.
title: The title of the layer as defined in the GetTiledService request.
uuid: A randomly generated unique ID for the layer.
Code Snippets
Create a new TWMSTiledWebMapService using a URL
TWMSTiledWebMapService *earthTwms = [[TWMSTiledWebMapService alloc] initWithUrl:[NSURL URLWithString:@"http://gibs.earthdata.nasa.gov/twms/epsg4326/best/twms.cgi?request=GetTileService"]];
List all map layers in a TWMS server
NSArray *tiledMapNames = [earthTwms listAllTiledMapsByName];
for(NSString *tiledMapName in tiledMapNames) {
NSLog(@"%@", tiledMapName);
}
Update variables for all TWMS endpoints
[earthTwms setTiledMapKeyValue:@"2012-07-12" forTiledMapKey:@"${time}"];
Add, reorder, and remove map layers (Provided by ArcGIS's MapView class)
AGSMapView *mapView = <the map view>;
TWMSTiledMap *tiledMap = <obtained from TWMSTiledWebMapService>;
TWMSTiledMapLayer *tiledMapLayer = [[TWMSTiledMapLayer alloc] initWithTiledMap:tiledMap];
[mapView addLayer:tiledMapLayer withName:[tiledMap uuid]];
[mapView insertMapLayer:tiledMapLayer withName:[tiledMap uuid] atIndex:<index>];
[mapView removeLayerWithName:[tiledMap uuid]];
Set map layer transparency (Provided by iOS UIView's transparency settings)
UIView *view = [[[mapView mapLayerViews] objectForKey:[tiledMap uuid]];
[view setAlpha:<transparency value>];