AirMapView Documentation

repository·master·Indexed 23 days ago

https://github.com/airbnb/airmapview

An Android view abstraction for interactive maps that supports multiple native providers, such as Google Maps V2 and Amazon Maps V2, with an automatic fallback to web-based maps for devices without Google Play Services.

Tokens
699
Snippets
3
Records
5
Agent score
34%

What's inside AirMapView

  1. What is AirMapView and its core features?

    master

    AirMapView is a view abstraction that provides interactive maps for devices regardless of whether they have Google Play Services installed.

    Key Features:

    • Provider Abstraction: Supports multiple native map providers (including Google Maps V2 and Amazon Maps V2).
    • Runtime Swapping: Ability to swap map providers at runtime.
    • Web Fallback: Automatically falls back to web-based maps (currently Google Maps) on devices without supported native map providers.
  2. Configure Native Google Maps setup

    master
    To support native Google Maps via the Google Maps v2 SDK, you must complete the standard Google Maps SDK setup (as described in Google's documentation). AirMapView handles the map implementation itself, so you do not need to manually add a map component from the Google SDK.
  3. Configure Mapbox Web setup

    master

    To use Mapbox Web maps as a fallback provider, you must provide your Mapbox ACCESS_TOKEN and MAP_ID in your AndroidManifest.xml using meta-data tags.

    <meta-data
        android:name="com.mapbox.ACCESS_TOKEN"
        android:value=ACCESS_TOKEN/>
    <meta-data
        android:name="com.mapbox.MAP_ID"
        android:value=MAP_ID/>
  4. How to use AirMapView

    master

    To integrate AirMapView into your application, follow these three steps:

    1. Add the AirMapView component to your XML layout file.
    2. Initialize the view in your Activity or Fragment using initialize(FragmentManager).
    3. Use the map object to add overlays like markers, polylines, or polygons.
    <!-- 1. Define in layout -->
    <com.airbnb.android.airmapview.AirMapView
        android:id="@+id/map_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    // 2. Initialize in code
    mapView = (AirMapView) findViewById(R.id.map_view);
    mapView.initialize(getSupportFragmentManager());
    
    // 3. Add markers/polylines/polygons
    map.addMarker(new AirMapMarker(latLng, markerId)
            .setTitle("Airbnb HQ")
            .setIconId(R.drawable.icon_location_pin));