Layers Overview
A map is basically an empty canvas onto which one or more layers are drawn. A wide variety of pre-defined layers are provided by the API.
Layer Types
Most layers display content from GIS server web services, such as ArcGIS Server services, Bing Maps, Open Street Map, etc. These layers fall into two broad categories – dynamic layers and tiled layers.
Dynamic layers rely on web services that generate map images on-the-fly when requested by a client. Tiled layers rely on web services that provide map images that have been generated ahead of time based on some tiling scheme . Tiled layers provide much better performance than dynamic layers because map images do not need to be generated when requested by the client, instead map images are readily available and only need to be transferred to the client.
A Graphic layer is a special type of dynamic layer. It does not rely on any web service for its content. Its content is made up of graphics that are added to the layer.
Web maps
A web map is not an individual layer, rather it is a reference to a configuration of multiple map layers and services authored and saved in ArcGIS Online. The web map is accessed via its uniform resource locator (URL) and is used to construct an entire map (MapView). Additional layers can be added to the web map. If this is required, use code rather than Extensible Markup Language (XML).
Web maps contain not only a number of layers but also configuration about the layers such as their transparency, name, and draw order. It also contains map configuration information such as the initial extent. Web maps can be secured or shared in groups or publicly.
Web maps contain many advantages to the traditional approach of defining individual map layers and configuration in your application. Quite often you will want to change the same configuration about the layers in your map or change the initial extent. With web maps, this can be done online and outside of your application code, reducing the need for application redeployment.
The functional and performance characteristics of a web map depend on the map service layers that it contains, (see the following sections).
A web map that is fully supported by the ArcGIS for Android API can contain any of the map layer types discussed in this topic.
Tiled map service layers
API classes: ArcGISTiledMapServiceLayer/BingMapsLayer—Tiled map service layers are connected to cached map services (either from ArcGIS Server or Bing), which provide map images at predefined scales within a tiling scheme. The tiling scheme is set by the server. The map image tiles are raster (also called bitmap) images that are drawn into the map view and arranged into their tiling scheme by the ArcGIS for Android API. These services can contain multiple map layers.
Functional characteristics
Because these images are pre-created by the server, it is not possible to change the visibility of the individual layers or the services default spatial reference of the map (they can be considered as static map services). In addition to this, the data cannot change over time unless the cache is refreshed. Within the ArcGIS for Android API, it is not possible to query the layers within a tiled map service. These layers are commonly used for basemaps.
Performance characteristics
Tiled map services are some of the fastest map services available in the ArcGIS for Android API. The map images are pre-created and cached by the server and are returned from the server very quickly. Multiple images are usually returned for a single map extent, which means the requests are multithreaded and handled asynchronously (tiles are requested and drawn individually from one another). This asynchronous model means there will be a lot of small requests to the server for this type of layer and there will be little client-side processing as images are drawn quickly. The size of each returned image increases as the resolution or complexity of the images increase. For example, high-resolution imagery tiles will be larger in file size than topographic mapping for the same area and map extent.
Dynamic map service layers
API class: ArcGISDynamicMapServiceLayer/ArcGISImageServiceLayer—A dynamic map service layer is a map that can contain multiple layers rendered by the server on every request and returned as a single raster image. The image does not contain any additional information about the features in the map. Dynamic map layers are connected to ArcGIS Server map services.
Functional characteristics
As map images are drawn by the server on every request, the data can change over time and will be seen by the user (as long as they request a new image since the change has taken place). In addition to this, the visibility of individual map layers can be changed and the data shown can be filtered by adding individual layer definition expressions. The spatial reference of this layer type can be changed from the services default and ArcGIS Server re-projects each image on-the-fly although there is no direct method for setting this, as the map's spatial reference is based on the first layer that is added.
Within the ArcGIS for Android API, there are no specific methods on the ArcGISDynamicMapServiceLayer class to query individual map layers. However, the layer's end point URL can be used as the basis for a feature layer or for a Query task.
Performance characteristics
For every map request, ArcGIS Server creates a map image on-the-fly and therefore, the rendering time depends on the amount and complexity of the data in the map. However, if the map service is well optimized, this should be relatively quick but will typically be longer than a tiled map service layer. The file size of the returned map image also depends on the data in the map but will be drawn on the map screen quickly as it requires little client-side processing. Therefore, it is a good candidate for showing features that change over time or require some sort of filtering by the user, as long as the feature information (attributes, geometry, or symbol) is not required.
It is often used in conjunction with a feature layer in selection mode to show the latest map data without having to pull all of the feature information from the server (as with feature layers) on every map request.
Graphics layers
API class name: GraphicsLayer—Graphics layers are application defined layers designed for drawing features with one of the available renderers or symbols. They can contain features of multiple geometry types. For more information on how to symbolize features in these layers, see Symbolize results sample.
Functional characteristics
The graphics layer is responsible for drawing features on the map in spatial coordinates. It is not designed for drawing non-geographical based features such as north arrows or copyright text. As this layer contains information on the features, it is possible to query the layer using screen coordinates to return features using the getGraphics() method. It is also possible to set the layer's scale threshold using the setMinScale or setMaxScale methods.
Performance characteristics
It is not recommended to add too many features to the graphics layer. However, it does perform well and is the basis of the feature layer class. If you are working with a lot of features, it may be more appropriate to put these into a feature layer as a feature collection (see the following).
Feature layers
API class: ArcGISFeatureLayer—Feature layers contain information about the features in the map on the client and the features are rendered individually using native graphics. These features are created from a JavaScript Object Notation (JSON) response from an ArcGIS Server feature service or map service (map service feature layers will not be editable).
Functional characteristics
Feature layers provide the richest functionality out of any of the layer types because they contain complete information about all of the features displayed on the map. They can also be created from ArcGIS Server feature services, which provide edit operations. The individual features in these layers can be queried and filtered based on spatial queries or text based WHERE clauses. The feature layer extends from the graphics layer, so all of the graphics layers operations are also available.
Performance characteristics
The rich functionality of the feature layer comes at a slight cost in terms of request processing times by ArcGIS Server, response processing times, and rendering speed. This is because the information about each feature is returned by the server, parsed and processed on the device, and drawn onto the screen. However, as long as these issues are understood and the settings of the feature layer are applied appropriately, they allow you to build exciting and functional applications with the ArcGIS for Android API. More detailed information on the feature layer's settings and how they affect the performance characteristics are discussed as follows.
Feature layer settings
There are some settings that can be applied to the ArcGIS for Android feature layer, which can change all aspects of the layer's performance including the request frequency profile, response size, and processing and rendering time. Please note, the best practice for setting up the services on the server side still need to be adhered to. These settings are mostly located in the ArcGISFeatureLayer.Options class but some are set on the feature layer class (remember, these need to be set after the layer has initialized).
Out fields—It is possible to limit the amount of attribute fields that are returned from the server with the outFields() method in the options class. This means that less data is sent over the network and processed in the response, as responses contain less information.
Max Allowable Offset—It is also possible to limit the number of vertices returned for each feature by the maxAllowableOffset() method. The value set in map units will be used to generalize the feature vertices on the server before the information is returned. There is no vertex closer to each other in each feature than this setting. It should not be used if you are editing the feature, as some vertexes will be missing and topological rules can easily be broken.
Mode—The ArcGISFeatureLayer class has the following three modes, which are discussed in turn as they significantly affect the functionality and performance:
- Snapshot mode—In snapshot mode, all of the features from the layer are immediately retrieved from the server after the layer is added to the map. This eliminates any need to return to the server for information, but can become cumbersome if the layer contains a large number, or complex features. The device may be overwhelmed by the number of features it needs to draw, or the service may reach its limit of how many features it can return at once. The default is 500 for ArcGIS Server 9.3.1 and 1000 for ArcGIS Server 10, but this limit is configurable on the server for each service. Use snapshot mode only with smaller datasets.
- On demand mode—In on demand mode, the features are retrieved as they are needed, requesting only the features within your current view extent or buffer (see the buffer factor setting). On demand mode requires more round-trips between the client and server, and should be used for showing that changes over time (either due to editing or time based data), as the latest data is always retrieved from the server (unless the new extent is completely contained within the current buffer or extent). On demand mode is also suitable for larger datasets with a lot of complex features, as it only retrieves the features that you need. However, sensible layer scale thresholds still need to be set on the service to ensure that a reasonable number of features are returned at any particular scale.
- Selection mode—Selection mode does not initially request any features from the server. Features are added only when a selection is made. This mode is useful when you cannot or do not want to bring all features into the client, but you want to highlight one or more features for a specific reason. For example, if you have a road's layer that's configured to use a custom symbology not supported for display using a feature layer, but you want to perform some web editing on the roads layer, which does require a feature layer, you can use a dynamic map service layer and a feature layer in selection mode. You would select the road to edit in the feature layer and this can be drawn using a simple client-side symbol. Once the edit is applied, you can clear the selection and refresh the dynamic map service to see the updated roads.
Feature collections—Although not strictly a mode, there is one other type of feature layer called a feature collection feature layer. A feature collection feature layer can be thought of as a snapshot feature layer created from a user-defined set of features. There is no server connection to consider and this type of feature exists only on the client; thus, no data is transferred over the network for this layer type. The ArcGISFeatureLayer class has an overloaded constructor for creating this type of layer. The layer is constructed using a FeatureSet (essentially an array of graphics) and a layer definition string, which is a JSON representation of a map layer (the same information returned by a Representational State Transfer [REST] request for a feature service layer or map service from ArcGIS Server). The layer definition can be changed as you like and should include at a minimum information on the layer name, geometry type, coordinate system, fields, and renderers.
The features in the feature set can be created manually in code, converted from some other source, or returned from a query from another ArcGIS Server service.
This layer can be queried like a normal feature layer including spatial queries using polygons as the local Geometry Engine is used. This layer cannot be edited using the applyEdits() method.
Buffer factor—For feature layers in on demand mode, it is possible to set a buffer factor to ensure that features are retrieved for an area around the current extent. Every time a map request occurs, features within this buffer will be returned; thus, increasing the amount of data returned from the server, which improves the user experience as these features are immediately visible.