Examples

The following are basic code and usage examples for using the AerisWeather SDK for iOS. For more detailed and advanced examples, review the code provided with the AerisWeather Demo application that is distributed with the SDK on Github.

Basic Data Requests

Basic Data Requests

Loading data from the AerisWeather API into your application using the iOS SDK is fast and simple. Just create an instance of the AWFWeatherEndpoint subclass you want to request data from or use the global shared instance, setup your request options and then perform the request.

Batch Request

Batch Request

Batch request support is available with the AerisWeather SDK for iOS, which is convenient for performing requests for data from multiple API endpoints with a single request. While each endpoint request still counts as a single access against your account's daily accesses, this method often results in much faster response times than performing each endpoint request individually.

Setting Up a Weather Map

While the AWFWeatherMapViewController class handles all of the setup necessary to get a fully-functional weather map up and running without any work, there may be times when you want more control over your own weather map.

Controlling Map Layer Order

Controlling Map Layer Order

When adding raster weather layers, such as radar or satellite, to your weather map using addSourceForLayerType:, they are rendered in the order in which they are added. So the last layer to be added will appear above all other layers.

Grouped Annotation Style

Grouped styles are used for most point and polygon data sources for a weather map. A grouped style categorizes model objects and their annotations based on varying criteria as defined by a series of model evaluator blocks. Then, a separate AWFMapItemStyle subclass is setup for each category in the group.

Updating map layer opacity

When using AerisWeather 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.

Creating a map options view

The built-in AWFMapOptionsViewController provides a quick and easy way to control the map layers and various options for an AWFWeatherMap instance. However, you may want to provide a custom map options view within your own applications instead of the built-in version.

Customizing annotation callout text

When presenting point data on your weather map using annotations, such as storm reports or earthquakes, the AerisWeather SDK for iOS will automatically format the text that is presented in an annotation’s callout view. In most cases this information will be sufficient. However, you may want to customize the text that is displayed for the title and/or subtitle of the annotation callout.

Customizing callout content views

In addition to just being able to customize the callout text for map annotations associated with weather layers, you can take this a step further and provide an entirely custom view to display in the callout instead of the standard title and subtitle. This allows you to display datasets and visuals in a unique way for your particular application beyond just text.

Adding custom annotations

Oftentimes you'll want to display your custom data on the map managed by AWFWeatherMap, such as custom annotations and/or overlays. However, since your AWFWeatherMap instance must remain the map view's delegate to retain the built-in weather layer functionality, you cannot change the map view's delegate.

Adding custom overlays

Oftentimes you'll want to display your custom data on the map managed by AWFWeatherMap, such as custom annotations and/or overlays. However, since your AWFWeatherMap instance must remain the map view's delegate to retain the built-in weather layer functionality, you cannot change the map view's delegate.

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.

Last modified: July 30, 2020