While simply adding and removing weather layers to your weather map by their type codes is sufficient in most use cases, you may find that you need to use some of the advanced features that AerisWeather Maps offers.
To do so, you should create an instance of
AWFRasterMapLayer initialized with the raster layer type or layer key you want to use for the layer, such as
AWFRasterMapLayer *layer = [AWFRasterMapLayer layerWithLayerType:AWFMapLayerRadar];
let layer = AWFRasterMapLayer(layerType: .radar)
While it's recommended to use
AWFMapLayer type/enumeration values, you can also create a map layer using the AerisWeather Maps layer key as a string. This method is useful if you need to use a newly-released map layer before a valid
AWFMapLayer type has been added for it within the AerisWeather SDK for iOS:
AWFRasterMapLayer *layer = [[AWFRasterMapLayer alloc] initWithLayerKey:@"radar"];
let layer = AWFRasterMapLayer(layerKey: "radar")
Once you have a map layer instance, you can now control how the layer will be displayed on your map, such as changing its opacity, adding filters or masks.
For instance, the following will set the above radar layer to an opacity of 80% with a blur of 2.0 and using an overlay blend mode:
layer.alpha = 0.8; layer.blurAmount = 2.0; layer.blendMode = AWFRasterBlendModeOverlay;
layer.alpha = 0.8 layer.blurAmount = 2 layer.blendMode = .overlay
After applying any of your desired layer modifiers, you can now add it to your weather map using the Maps layer controller:
The layer will automatically be added to the top of any other AerisWeather Maps layers already on the map. Alternatively, you can insert the new layer at a specific index relative to existing Maps layers:
[self.weatherMap.amp addRasterLayer:layer atIndex:2];
weatherMap.amp.addRasterLayer(layer, at: 2)
Refer to the AWFRasterMapLayer documentation for the complete list of properties and methods available and how they correspond to various AerisWeather Maps features.
Removing a specific AerisWeather Map layer is done similarly by using
Note that using this method to remove a Maps layer requires you to provide the actual map layer instance that was originally added using
addRasterLayer:, which differs from the basic approach of adding and removing Maps layers by their layer types where these instances are managed automatically by the weather map.
Some AerisWeather Maps layers also support text layers that correspond to the raster data, such as temperatures, winds and dew points. These layers will have the
-text suffix on their layer code string.
If you are adding a raster layer, such as temperatures or wind speeds, and want to add the text layer along with it, you can use the property
includeTextData on your map layer instance:
AWFRasterMapLayer *layer = [AWFRasterMapLayer layerWithLayerType:AWFMapLayerTemperatures]; layer.includeTextData = YES; [self.weatherMap.amp addRasterLayer:layer];
let layer = AWFRasterMapLayer(layerType: .temperatures) layer.includeTextData = true weatherMap.amp.addRasterLayer(layer)
This will add the text layer on top of the base layer specified by the provided layer type or code and remove it when the parent raster layer associated with it is removed from the weather map.
HEADS UP! Adding a raster map layer that also includes a text layer such as in the above example will add two separate layers to your weather map, meaning each tile or image request for that layer will actually count as separate map units. Refer to our information on map units and daily accesses for more details regarding how map units are measured.
However, you may want to display just the text layer without the raster image data underneath it, such as showing temperature text over radar. The method is very similar to that above, but instead you will need to use the
AWFRasterMapLayer *layer = [AWFRasterMapLayer layerWithLayerType:AWFMapLayerTemperatures]; layer.isTextLayer = YES; [self.weatherMap.amp addRasterLayer:layer];
let layer = AWFRasterMapLayer(layerType: .temperatures) layer.isTextLayer = true weatherMap.amp.addRasterLayer(layer)
This will tell the weather map to only include the temperature text layer without the colored gradient image data underneath it.
includeTextData property method above, using this method requires you to implicitly remove the text layer even if you add a separate raster, non-text layer to the weather map with the same layer code or type.
Last modified: August 02, 2021