AirMapView: A View Abstraction for Maps on Android

Apr 20, 2015 · 3 min read

By Eric Petzel

Image for post
Image for post

Many Android applications today require some form of an interactive map as part of their user interface. Google provides a native package and experience with Google Play Services to satisfy this need, but the question remains of how one creates interactive maps for devices without Play Services.

In some countries, the majority of devices are sold without Google Play Services. Device manufacturers who ship their devices without Play Services are continuing to gain popularity worldwide. In order for our application to provide a truly internationalized experience, we can’t leave out a feature as critical as maps. And because we know other companies have this same issue, we’ve created and open sourced AirMapView.

AirMapView is a view abstraction that enables interactive maps for devices with and without Google Play Services. Devices that do have Google Play Services will use Google Maps V2, while devices without will use a web based implementation of Google Maps. This all comes as one single API that is designed after that of Google Maps V2 that most developers are used to.

AirMapView will choose by default the best map provider available for the device. By default it will use native Google Maps V2 if available and fallback to a WebView solution if Google Play Services are not available. The API is designed to be completely transparent to the user so that developers can use the same APIs that are currently used for Google Maps to gain the fallback functionality.

Native GoogleMap is implemented as a Fragment inside of the AirMapView providing the exact same functionality as using Google Maps V2 directly. Porting existing implementations from GoogleMap to AirMapView is as simple as replacing calls to GoogleMap with calls to AirMapView and implementing the correct callback classes for operations such as OnCameraChanged. The API is designed to be pluggable so developers can add their own providers for specific devices such as Amazon Maps for Amazon kindle fire devices.

The fallback webview map displays a Google Map inside of an Android WebView and uses the javascript bridge callbacks to allow dynamic interaction with the map. Due to it being a webview and not native code it isn’t as performant as the native GoogleMap but it only performed slightly worse in experiments in the Airbnb app.

Using the Javascript Bridge we are able to implement the same API in the web map so no client code changes are required to support the web map once AirMapView has been implemented for native maps.

The web map allows setting a location, centering, adding markers, dragging, tapping on the map and other common operations that are currently supported in the GoogleMap.

We’ve built AirMapView in such a way that allows us to easily add additional map providers in the future, such as Amazon Maps V2, Baidu, Mapbox, etc.

For more information take a look at our Github page here:

Image for post
Image for post

Check out all of our open source projects over at and follow us on Twitter: @AirbnbEng + @AirbnbData

Originally published at on April 20, 2015.

Airbnb Engineering & Data Science

Creative engineers and data scientists building a world…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store