Weather Maps

The AerisMapKit module of the Aeris Weather SDK for iOS provides a fully-functional interactive weather map that you can easily drop into your custom application to display any type of weather data currently offered from the Aeris Maps Platform (AMP) and Aeris Weather API. This weather map is highly configurable and customizable, giving you even more control over how it integrates into your project.


Supported Map Libraries

The AerisMapKit module of the SDK works with the following mapping libraries. The default mapping library is Apple Maps using MapKit:

When you instantiate an instance of a weather map object, you must specify which mapping library you want to use and cannot be changed once the weather map is created. The weather map object will automatically handle setting up your map view and the addition and removal of map overlays and objects based on the mapping strategy you choose.

Creating a Basic Weather Map

The simplest method for setting up a weather map is to instantiate an instance of AWFWeatherMap with the desired map type. If you don't provide a map type, then the default of AWFWeatherMapTypeApple will be used:

AWFWeatherMap *weatherMap = [[AWFWeatherMap alloc] initWithMapType:AWFWeatherMapTypeApple];
let weatherMap = AWFWeatherMap(mapType: .apple)

This initializes will also use the default map configuration and styling. If you want to provide a different configuration, then you will also need to specify your custom AWFWeatherMapConfig instance:

AWFWeatherMap *weatherMap = [[AWFWeatherMap alloc] initWithMapType:nil config:[MyWeatherMapConfig config]];
let weatherMap = AWFWeatherMap(mapType: .apple, config: MyWeatherMapConfig())

Refer to the configuration guide for additional information regarding map configuration customizations.

Once you have a weather map instance, you'll need to add the weather map view to your application's view hierarchy and set its frame or layout constraints. You must use the weatherMapView, not the weather map's mapView property, when setting up your weather map. The weatherMapView is a container view that includes the map view for the chosen mapping library, such as MKMapView or MGLMapView, and other internal subviews required for various weather map functionality.

So, use weatherMapView in place of where you would use MKMapView or other map view:

weatherMap.weatherMapView.frame = self.view.bounds;
[self.view addSubview:weatherMap.weatherMapView];
weatherMap.weatherMapView.frame = view.bounds

If you need to receive event messages for various events triggered by an AWFWeatherMap instance, such as when data sources are added to or removed from the map or the state of animations, you'll need to assign the weather map's delegate property and conform to the AWFWeatherMapDelegate protocol:

weatherMap.delegate = self;
weatherMap.delegate = self

Creating a Weather Map Using AWFWeatherMapViewController

To get a fully-interactive and functional weather map up and running similar to that in our SDK's demo application requires much more setup than creating a basic weather map instance as the section above demonstrated. Therefore, we've wrapped all of the core weather map functionality into the AWFWeatherMapViewController class that you can simply drop into your project with little effort.

AWFWeatherMapViewController sets up everything you need for a fully interactive weather map, including:

  • weather map and map view instances
  • timeline/animation control view
  • data legend view
  • options menu for toggling map data sources on and off
  • handling of the various weather map events by implementing the AWFWeatherMapDelegate protocol

By default, AWFWeatherMapViewController will instantiate a default instance of AWFWeatherMap that uses Apple's MapKit and the default configuration and styles. You can override these defaults by setting the weatherMapType and config properties on your map controller instance before adding the weather map view to your view hierarchy:

// MyWeatherMapConfig is a subclass of AWFWeatherMapConfig
MyWeatherMapConfig *mapConfig = [MyWeatherMapConfig config];
AWFWeatherMapViewController *weatherMapController = [[AWFWeatherMapViewController alloc] initWithNibName:nil bundle:nil];
weatherMapController.weatherMapType = AWFWeatherMapTypeApple;
weatherMapController.config = mapConfig;
let mapConfig = MyWeatherMapConfig()
let weatherMapController = AWFWeatherMapViewController()
weatherMapController.weatherMapType = .apple
weatherMapController.config = mapConfig

Alternatively, you can subclass AWFWeatherMapViewController and override the above properties at initialization:

@implementation MyWeatherMapViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // MyWeatherMapConfig is a subclass of AWFWeatherMapConfig
        MyWeatherMapConfig *mapConfig = [MyWeatherMapConfig config];
        self.weatherMapType = AWFWeatherMapTypeApple;
        self.config = mapConfig;
        self.autorefreshEnabled = YES;
    return self;
class MyWeatherMapViewController: AWFWeatherMapViewController {
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        self.weatherMapType = .apple
        self.config = MyWeatherMapConfig()
        self.isAutorefreshEnabled = true
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")

For implementations that require even more advanced levels of customization and control, you should subclass AWFWeatherMapViewController and override the necessary options and/or methods. Review the API reference for AWFWeatherMapViewController for the complete list of public properties and methods available.

Receiving Map View Delegate Messages

Since your weather map and its internal objects must remain the sole delegate for your map view, you must NOT set the delegate property on a weather map's map view directly.

Therefore, to use a weather map while still responding to map view delegate messages, such as those from MKMapViewDelegate, you must set the mapViewDelegate property on your weather map instance to the object that acts as the delegate:

weatherMap.mapViewDelegate = self;
weatherMap.mapViewDelegate = self

Note that this is NOT the same as setting the delegate on your weather map instance.