Updating Map Layer Opacity

When using Aeris Maps (AMP) 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 AMP 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:

ObjectiveC
Swift
AWFRasterMapLayer *tempsLayer = [AWFRasterMapLayer layerWithLayerType:AWFMapLayerTemperatures];
tempsLayer.alpha = 0.5;
[self.weatherMap.amp addRasterLayer:tempsLayer];
let tempsLayer = AWFRasterMapLayer(layerType: .temperatures)
tempsLayer.alpha = 0.5
weatherMap.amp.addRasterLayer(tempsLayer)

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

ObjectiveC
Swift
AWFRasterMapLayer *tempsLayer = [self.weatherMap.amp rasterLayerForLayerType:AWFMapLayerTemperatures];
if (tempsLayer) {
    tempsLayer.alpha = 0.7;
    [self.weatherMap refreshAllSources];
}
if let tempsLayer = weatherMap.amp.rasterLayer(forLayerType: .temperatures) {
    tempsLayer.alpha = 0.7
    weatherMap.refreshAllSources()
}

Alternatively, you can set the opacity for all AMP layers by accessing the AWFTileSource associated with all AMP layers and setting it’s alpha property:

ObjectiveC
Swift
self.weatherMap.amp.tileLayer = 0.5;
weatherMap.amp.tileLayer.alpha = 0.5

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