Raster Maps Usage

Using Xweather Raster Maps Features

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 (opens in a new tab) that Xweather Raster Maps offers.

Adding Xweather Raster Maps Layers

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 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 Xweather Raster 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 Xweather iOS SDK:

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
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:

weatherMap.amp.addRasterLayer(layer)

The layer will automatically be added to the top of any other Xweather Raster Maps layers already on the map. Alternatively, you can insert the new layer at a specific index relative to existing Raster Maps layers:

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 Xweather Raster Maps features.

Removing Xweather Raster Maps Layers

Removing a specific Xweather Map layer is done similarly by using removeRasterLayer:

weatherMap.amp.removeRasterLayer(layer)

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.

Using Xweather Raster Maps Text Layers

Some Xweather Raster 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 (opens in a new tab) 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:

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.

[screenshot]

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 isTextLayer property:

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.

[screenshot]

Unlike the 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.