Skip to Content
Getting StartedWeather maps

Android SDK - 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.

fragment_interactive_maps.xml
<LinearLayout mlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <com.aerisweather.aeris.maps.AerisMapContainerView android:id="@+id/mapView" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>

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.

MyMapFragment.java
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; @Override 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(R.id.mapView); m_aerisMapView = mapContainer.getAerisMapView(); m_aerisMapView.onCreate(savedInstanceState); //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 try { //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.

@Override public void onMapReady(GoogleMap googleMap) { m_isMapReady = true; m_googleMap = googleMap; m_aerisMapView.init(googleMap); if (m_isAmpReady) { initMap(); } }

Using layers

Weather maps can be customized with many different layers, even more so with the addition of Xweather Raster Maps.

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 m_aerisMapView.addLayer(AerisPointData.STORM_REPORTS); //polygons m_aerisMapView.addLayer(AerisPolygonData.FIRE_OUTLOOK);

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

//saved point data m_aerisMapView.addLayer(m_mapOptions.getPointData()); //saved polygons m_aerisMapView.addLayer(m_mapOptions.getPolygonData();

To remove point and polygon layers from your map:

// remove point data layer aerisMapView.removePointsLayer(); // remove point data layer aerisMapView.removePolygonLayer();

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 m_mapOptions.setDefaultAmpLayers();

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") aerisAmp.removeLayer(layer); }
© 2026 Xweather (opens in a new tab)Terms of Service (opens in a new tab)Privacy Policy (opens in a new tab)