Customizing Map Data Requests

Vector point and polygon layers, such as storm cells, storm reports, and convective outlooks, are configured with default request options that should work in most cases. However, you may need to adjust the data requests associated with a particular layer in your own AWFWeatherMap implementation.

To override the default request options associated with a vector data layer, you'll need to conform to the AWFWeatherMapDataSource protocol and implement the protocol's weatherMap:requestOptionsForLayer: method. This method will provide you with the enumerated AWFMapLayer value for the data layer that is going to perform the data request. Your implementation must then return an instance of AWFWeatherRequestOptions if you want custom options for the specific layer's request. If you want to fall back to the default options the SDK provides, then just return nil for that layer.

The following example overrides the default request for the vector tropical cyclones layer, AWFMapLayerTropicalCyclones, and configures it to return test storm data instead of the latest information:

ObjectiveC
Swift
extension MapViewController: AWFWeatherMapDataSource {
    
    override func weatherMap(_ weatherMap: AWFWeatherMap, requestOptionsForLayer layerType: AWFMapLayer) -> AWFWeatherRequestOptions? {
        var options: AWFWeatherRequestOptions?
        
        if layerType == .tropicalCyclones {
            options = AWFWeatherRequestOptions()
            options?.filterString = "\(AWFTropicalCycloneFilter.test)"
            options?.limit = 100
        }
        
        return options
    }
}
- (AWFWeatherRequestOptions *)weatherMap:(AWFWeatherMap *)weatherMap requestOptionsForLayer:(AWFMapLayer)layerType {
    AWFWeatherRequestOptions *options = nil;
    
    if (layerType == AWFMapLayerTropicalCyclones) {
        options = [AWFWeatherRequestOptions new];
        options.filterString = AWFTropicalCycloneFilterTest;
        options.limit = 100;
    }
    
    return options;
}

Note that the request's date ranges are managed by the weather map and the layer's data source and cannot be overridden using this method.

Last modified: May 21, 2020