Weather maps

Weather maps

The weather map feature requires you to include the com.aerisweather.aeris.maps.AerisMapViewContainer in your layout XML where you would like the map to appear. The map includes support for Xweather Raster Maps layers (radar, satellite, etc). Point data (storm cells, storm reports) and polygon data (convective, drought, fire). There are also features to to allow animation of these overlays and more.

Creating a weather map

To begin, we need to add the com.aerisweather.aeris.maps.AerisMapContainerView to your layout XML.

            android:layout_height="match_parent" /> 

The AerisMapContainerView contains a reference to the AerisMapView class, which is derived from GoogleMapView. This will be the main class used to access your weather map, as well as the AnimationView used to draw the images used for animating the map.

Initializing the map

In order to initialize the map and the various overlay controlls and settings you will need to import the AerisMapView within your code. Notice too that we must implement the OnMapReadyCallback function. This is how Google Maps tells us that the map is ready for us to work with.
package com.example.fragment
public class MyMapFragment extends Fragment implements
        OnAerisMapLongClickListener, AerisCallback, ObservationsTaskCallback,
        OnAerisMarkerInfoWindowClickListener, RefreshInterface, OnMapReadyCallback
    private LocationHelper m_locHelper;
    private Marker m_marker;
    private TemperatureWindowAdapter m_infoAdapter;
    private static final int REQUEST_PERMISSIONS = 0;
    LayoutInflater m_inflater;
    ViewGroup m_container;
    Bundle m_savedInstanceState;
    GoogleMap m_googleMap;
    protected AerisMapView m_aerisMapView;
    private AerisMapOptions m_mapOptions = null;
    private AerisAmp m_aerisAmp;
    private boolean m_isMapReady = false;
    private boolean m_isAmpReady = false;
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        m_inflater = inflater;
        m_container = container;
        m_savedInstanceState = savedInstanceState;
        View view = inflater.inflate(R.layout.fragment_interactive_maps, container, false);
        AerisMapContainerView mapContainer = (AerisMapContainerView) view.findViewById(;
        m_aerisMapView = mapContainer.getAerisMapView();
        //create an instance of the AerisAmp class
        m_aerisAmp = new AerisAmp(getString(R.string.aerisapi_client_id), getString(R.string.aerisapi_client_secret));
        //start the task to get the Raster Maps layers
            //get all the possible layers, then get permissions from the API and generate a list of permissible layers
            new AerisAmpGetLayersTask(new GetLayersTaskCallback(), m_aerisAmp).execute().get();
        catch (Exception ex)
            String s = ex.getMessage();
            //if the task fails, keep going without Raster Maps layers
        return view;

When the map is ready, our callback is fired and we can continue with initializing the map as needed.

    public void onMapReady(GoogleMap googleMap)
        m_isMapReady = true;
        m_googleMap = googleMap;
        if (m_isAmpReady)

Using layers

Weather maps can be customized with many different layers, even more so with the addition of Xweather Raster Maps (opens in a new tab).

Point and polygon data

To add a point or polygon layer to the map, we call the addLayer method on the AerisMapView instance, such as:

//point data - show the storm reports from the past 24 hours

or retrieve the layers from the device's saved preferences:

//saved point data
//saved polygons 

To remove point and polygon layers from your map:

// remove point data layer
// remove point data layer

Raster Maps layers

Displaying Raster Maps weather layers on your map can be achieved in a few different ways. Create an AerisAmpLayer object for each desired raster layer, and add them to the parent AerisRaster Maps object.

AerisAmpLayer aerisAmpLayer = new AerisAmpLayer(); //creates a radar layer by default
aerisRaster Maps.setLayer(aerisAmpLayer);

or simply passing in the name or id of an existing Raster Maps layer:

//add the radar layer
aerisRaster Maps.setLayerFromName("radar");
//add the satellite layer
aerisRaster Maps.setLayerFromId("sat");

or we can just set the default layers:

//set default layers/data

To remove a Raster Maps layer, simply get the AerisAmpLayer from the AerisAmp object's active layer list and pass that layer to the removeAmpLayer(AerisAmpLayer) method:

ArrayList layers = aerisAmp.getActiveMapLayers();
for (AerisAmpLayer layer: layers)
    if (layer.getLayerId() == "sat")