Updating map layer opacity

Updating map layer opacity

When using Xweather Raster Maps weather layers in a weather map, you can use more customization options by using instances of AWFRasterMapLayer and added them to your weather map. In this case, you will often be accessing the amp property on your AWFWeatherMap instance, which is just the tile content source provider responsible for managing all Maps layers on the map.

For instance, you can specify a custom opacity value for a single layer by using the AWFRasterMapLayer class and adding it to your weather map at instantiation:

let tempsLayer = AWFRasterMapLayer(layerType: .temperatures)
tempsLayer.alpha = 0.5

However, you may need to update the opacity on a layer or for all layers after the layer has already been added to the weather map, such as in response to a slide control. You can also achieve this by getting the AWFRasterMapLayer instance and updating it's alpha property for a single Maps layer:

if let tempsLayer = weatherMap.amp.rasterLayer(forLayerType: .temperatures) {
    tempsLayer.alpha = 0.7

Alternatively, you can set the opacity for all Xweather Raster Maps layers by accessing the AWFTileSource associated with all Maps layers and setting it's alpha property:

weatherMap.amp.tileLayer.alpha = 0.5

Refer to the AWFRasterMapLayer class documentation for additional information on customizing individual Maps layers.