SDK Configuration


The Android Maps SDK allows developers to create maps in their applications using the NextbillionMapOptions configuration. This configuration class defines the default values and states for a MapView, providing various options for customization. With NextbillionMapOptions, developers can easily configure the maps in their applications to meet their specific needs.



The below code snippet is a part of the Camera class in the Android Maps SDK. It defines several variables used to control the camera view of a map. The cameraPosition variable stores the current camera position of the map, while the minZoom and maxZoom variables set the minimum and maximum zoom level allowed. The minPitch and maxPitch variables set the minimum and maximum pitch angle of the camera. These variables work together to control the camera view of the map and ensure that it stays within the desired range of values. The values are taken from the NbmapConstants class, which provides constants that define the minimum and maximum values for various parameters in the map view.

1  private CameraPosition cameraPosition;
2  private double minZoom = NbmapConstants.MINIMUM_ZOOM;
3  private double maxZoom = NbmapConstants.MAXIMUM_ZOOM;
4  private double minPitch = NbmapConstants.MINIMUM_PITCH;
5  private double maxPitch = NbmapConstants.MAXIMUM_PITCH;

cameraPosition: The initial coordinate of a MapView will be at (0, 0), we can configure the initial coordinate with this field. Meanwhile, cameraPosition has defined these configurable values:

1  public final double bearing;
3  /**
4   * The location that the camera is pointing at.
5   */
6  public final LatLng target;
8  /**
9   * The angle, in degrees, of the camera angle from the nadir (directly facing the Earth).
10   */
11  public final double tilt;
13  /**
14   * Zoom level near the center of the screen. 
15   */
16  public final double zoom;
18  /**
19   * Padding in pixels. Specified in left, top, right, and bottom order.
20   */
21  public final double[] padding;

The other fields are straightforward, and define a range of supported zoom and pitch/tilt of a MapView.

UI control

1  private boolean compassEnabled = true;
2  private boolean fadeCompassFacingNorth = true;
3  private int compassGravity = Gravity.TOP | Gravity.END;
4  private int[] compassMargins;
5  private Drawable compassImage;
7  private boolean logoEnabled = true;
8  private int logoGravity = Gravity.BOTTOM | Gravity.START;
9  private int[] logoMargins;
10  @ColorInt
11  private int attributionTintColor = UNDEFINED_COLOR;
12  private boolean attributionEnabled = true;
13  private int attributionGravity = Gravity.BOTTOM | Gravity.START;
14  private int[] attributionMargins;

The configuration defines gravity, margins, and toggle-flag for Compass, Logo, and Attribution.

The "fadeCompassFacingNorth" flag is set to "true", which means the compass icon on the map view will be hidden when the map view is facing north. When this flag is set to "true", the compass will not be visible on the map when it is rotated to face north.


The code defines the flags for various gestures that are supported by a map view. Each flag determines whether the corresponding gesture is enabled or not. For example, "rotateGesturesEnabled" is set to "true", which means that the map view will support the gesture of rotating. Similarly, "scrollGesturesEnabled" is set to "true", which means the map view will support the gesture of scrolling. The other flags (horizontalScrollGesturesEnabled, tiltGesturesEnabled, zoomGesturesEnabled, doubleTapGesturesEnabled, and quickZoomGesturesEnabled) have the same purpose and determine whether their respective gestures are supported in the map view.

1  private boolean rotateGesturesEnabled = true;
2  private boolean scrollGesturesEnabled = true;
3  private boolean horizontalScrollGesturesEnabled = true;
4  private boolean tiltGesturesEnabled = true;
5  private boolean zoomGesturesEnabled = true;
6  private boolean doubleTapGesturesEnabled = true;
7  private boolean quickZoomGesturesEnabled = true;

These are flags to turn on and off for supported gestures.

Base URI & Map Tiles

1The code is for a mapping application and defines several variables for the SDK. 
2  private String apiBaseUri;
3  private boolean prefetchesTiles = true;
4  private int prefetchZoomDelta = 4;
5 @ColorInt
6  private int foregroundLoadColor;

The "apiBaseUri" variable specifies the host for the Maps SDK to connect to. The "prefetchesTiles" and "prefetchZoomDelta" variables control the behavior of map tile prefetching. Finally, the "foregroundLoadColor" variable determines the color of the page before the map tile is loaded.

Glyphs and Font

1  private boolean localIdeographFontFamilyEnabled = true;
2  private String localIdeographFontFamily;
3  private String[] localIdeographFontFamilies;

This code snippet declares three variables related to font handling:

  1. localIdeographFontFamilyEnabled: a boolean variable that determines whether the local ideograph font family is enabled. If set to true, it means that the local ideograph font family is enabled.

  2. localIdeographFontFamily: a string variable that stores the name of the local ideograph font family.

  3. localIdeographFontFamilies: an array of strings that holds the names of the local ideograph font families.

How to configure

Configure from XML

If we add a MapView from XML layout, we can configure the maps in this way:

1    <ai.nextbillion.maps.core.MapView
2        android:id="@id/mapView"
3        android:layout_width="match_parent"
4        android:layout_height="match_parent"
5        app:nbmap_baseUri=""
6        app:nbmap_cameraTargetLat="12.99150562"
7        app:nbmap_cameraTargetLng="77.61940507"
8        app:nbmap_cameraZoom="10" />

This code defines an XML layout that adds a MapView component. This component is part of the NextBillion maps library and is used to display a map on the screen. The MapView component is specified with the following attributes:

  1. android: an ID used to uniquely identify the MapView component in the layout.

  2. android and android: the width and height of the MapView component, respectively. They are set to match_parent which means the component will occupy the entire parent layout.

  3. app: the base URL used to access the NextBillion maps API. The value is set to

  4. app and app: the latitude and longitude of the target location to be displayed on the map, respectively. The values are set to 12.99150562 and 77.61940507.

  5. app: the zoom level of the camera. The value is set to 10, which means that the map will be zoomed in to a level where objects on the map will appear 10 times larger than at the default zoom level.

This XML layout is used to configure the display of the map, including the URL of the API, the location to be displayed, and the zoom level.

Available attributes

The Android Maps SDK provides a rich set of attributes that allow developers to customize the appearance and behavior of maps in their applications. These attributes provide fine-grained control over various aspects of maps, such as camera position, zoom level, map style, and markers. With these attributes, developers can create maps that meet the specific needs of their applications and provide a seamless user experience. By using the available attributes, developers can ensure that their maps are visually appealing and provide accurate and up-to-date information.

1   <!--Camera-->
2   <attr name="nbmap_cameraTargetLat" format="float" />
3   <attr name="nbmap_cameraTargetLng" format="float" />
4   <attr name="nbmap_cameraZoom" format="float" />
5   <attr name="nbmap_cameraBearing" format="float" />
6   <attr name="nbmap_cameraTilt" format="float" />
7   <attr name="nbmap_cameraZoomMax" format="float" />
8   <attr name="nbmap_cameraZoomMin" format="float" />
9   <attr name="nbmap_cameraPitchMax" format="float" />
10   <attr name="nbmap_cameraPitchMin" format="float" />
12   <!--Gestures-->
13   <attr name="nbmap_uiZoomGestures" format="boolean" />
14   <attr name="nbmap_uiScrollGestures" format="boolean" />
15   <attr name="nbmap_uiHorizontalScrollGestures" format="boolean" />
16   <attr name="nbmap_uiRotateGestures" format="boolean" />
17   <attr name="nbmap_uiTiltGestures" format="boolean" />
18   <attr name="nbmap_uiDoubleTapGestures" format="boolean" />
19   <attr name="nbmap_uiQuickZoomGestures" format="boolean" />
22   <!--UI control-->
23   <!--Compass-->
24   <attr name="nbmap_uiCompass" format="boolean" />
25   <attr name="nbmap_uiCompassGravity">
26       <flag name="top" value="0x30" />
27       <flag name="bottom" value="0x50" />
28       <flag name="left" value="0x03" />
29       <flag name="right" value="0x05" />
30       <flag name="center_vertical" value="0x10" />
31       <flag name="fill_vertical" value="0x70" />
32       <flag name="center_horizontal" value="0x01" />
33       <flag name="fill_horizontal" value="0x07" />
34       <flag name="center" value="0x11" />
35       <flag name="fill" value="0x77" />
36       <flag name="clip_vertical" value="0x80" />
37       <flag name="clip_horizontal" value="0x08" />
38       <flag name="start" value="0x00800003" />
39       <flag name="end" value="0x00800005" />
40   </attr>
41   <attr name="nbmap_uiCompassMarginLeft" format="dimension" />
42   <attr name="nbmap_uiCompassMarginTop" format="dimension" />
43   <attr name="nbmap_uiCompassMarginRight" format="dimension" />
44   <attr name="nbmap_uiCompassMarginBottom" format="dimension" />
45   <attr name="nbmap_uiCompassFadeFacingNorth" format="boolean" />
46   <attr name="nbmap_uiCompassDrawable" format="reference" />
48   <!--Logo-->
49   <attr name="nbmap_uiLogo" format="boolean" />
50   <attr name="nbmap_uiLogoGravity">
51       <flag name="top" value="0x30" />
52       <flag name="bottom" value="0x50" />
53       <flag name="left" value="0x03" />
54       <flag name="right" value="0x05" />
55       <flag name="center_vertical" value="0x10" />
56       <flag name="fill_vertical" value="0x70" />
57       <flag name="center_horizontal" value="0x01" />
58       <flag name="fill_horizontal" value="0x07" />
59       <flag name="center" value="0x11" />
60       <flag name="fill" value="0x77" />
61       <flag name="clip_vertical" value="0x80" />
62       <flag name="clip_horizontal" value="0x08" />
63       <flag name="start" value="0x00800003" />
64       <flag name="end" value="0x00800005" />
65   </attr>
66   <attr name="nbmap_uiLogoMarginLeft" format="dimension" />
67   <attr name="nbmap_uiLogoMarginTop" format="dimension" />
68   <attr name="nbmap_uiLogoMarginRight" format="dimension" />
69   <attr name="nbmap_uiLogoMarginBottom" format="dimension" />
71   <!--Attribution-->
72   <attr name="nbmap_uiAttribution" format="boolean" />
73   <attr name="nbmap_uiAttributionGravity">
74       <flag name="top" value="0x30" />
75       <flag name="bottom" value="0x50" />
76       <flag name="left" value="0x03" />
77       <flag name="right" value="0x05" />
78       <flag name="center_vertical" value="0x10" />
79       <flag name="fill_vertical" value="0x70" />
80       <flag name="center_horizontal" value="0x01" />
81       <flag name="fill_horizontal" value="0x07" />
82       <flag name="center" value="0x11" />
83       <flag name="fill" value="0x77" />
84       <flag name="clip_vertical" value="0x80" />
85       <flag name="clip_horizontal" value="0x08" />
86       <flag name="start" value="0x00800003" />
87       <flag name="end" value="0x00800005" />
88   </attr>
89   <attr name="nbmap_uiAttributionMarginLeft" format="dimension" />
90   <attr name="nbmap_uiAttributionMarginTop" format="dimension" />
91   <attr name="nbmap_uiAttributionMarginRight" format="dimension" />
92   <attr name="nbmap_uiAttributionMarginBottom" format="dimension" />
93   <attr name="nbmap_uiAttributionTintColor" format="color" />
95   <!--Base Uri and Map tile-->
96   <attr name="nbmap_baseUri" format="string" />
97   <attr name="nbmap_foregroundLoadColor" format="color" />
98   <attr name="nbmap_enableTilePrefetch" format="boolean" />
99   <attr name="nbmap_prefetchZoomDelta" format="integer" />
101   <!--Glyph and Font-->
102   <attr name="nbmap_localIdeographEnabled" format="boolean" />
103   <attr name="nbmap_localIdeographFontFamily" format="string" />
104   <attr name="nbmap_localIdeographFontFamilies" format="reference" />

Configure programmatically

The Android Maps SDK provides the ability to programmatically integrate maps into an application by using the MapView class. To configure the map display, developers can create an instance of NextbillionMapOptions and pass it when creating a MapView.

One way to create a default NextbillionMapOptions is by calling the static method NextbillionMapOptions.createFromAttributes(Context context). This method creates an instance of NextbillionMapOptions with default settings based on the current context.

Once an instance of NextbillionMapOptions is created, it can be customized by calling the available setters. For example, in the code snippet:

1NextbillionMapOptions options = NextbillionMapOptions.createFromAttributes(this, null)
2      .attributionTintColor(BLUE_COLOR)
3      .apiBaseUri("")
4      .compassFadesWhenFacingNorth(false)
5      .camera(new CameraPosition.Builder()
6        .target(new LatLng(5.727531563481325, 102.11544099540563))
7        .zoom(7)
8        .tilt(0)
9        .build());
11mapView = new MapView(this, options);

The NextbillionMapOptions instance is created with the default settings and then modified to set the attribution tint color to blue, the API base URI to, to prevent the compass from fading when facing north, and to set the camera position to a specific location with a zoom level of 7 and a tilt of 0 degrees.

Finally, the MapView is created by passing the customized NextbillionMapOptions instance.

Available setters

The Android Maps SDK provides a comprehensive set of setters that allow developers to fully customize the appearance and behavior of maps in their applications. These setters offer fine-grained control over various aspects of maps, such as camera position, zoom level, map style, and markers. With these setters, developers can create maps that meet the specific needs of their applications and provide a seamless user experience.

2public NextbillionMapOptions camera(CameraPosition cameraPosition)
3public NextbillionMapOptions minZoomPreference(double minZoom)
4public NextbillionMapOptions maxZoomPreference(double maxZoom)
5public NextbillionMapOptions minPitchPreference(double minPitch)
6public NextbillionMapOptions maxPitchPreference(double maxPitch)
8//UI control
9public NextbillionMapOptions compassEnabled(boolean enabled)
10public NextbillionMapOptions compassGravity(int gravity)
11public NextbillionMapOptions compassMargins(int[] margins)
12public NextbillionMapOptions compassFadesWhenFacingNorth(boolean compassFadeWhenFacingNorth)
13public NextbillionMapOptions compassImage(Drawable compass)
14public NextbillionMapOptions logoEnabled(boolean enabled)
15public NextbillionMapOptions logoGravity(int gravity)
16public NextbillionMapOptions logoMargins(int[] margins)
17public NextbillionMapOptions attributionEnabled(boolean enabled)
18public NextbillionMapOptions attributionGravity(int gravity)
19public NextbillionMapOptions attributionMargins(int[] margins)
20public NextbillionMapOptions attributionTintColor(@ColorInt int color)
23public NextbillionMapOptions rotateGesturesEnabled(boolean enabled)
24public NextbillionMapOptions scrollGesturesEnabled(boolean enabled)
25public NextbillionMapOptions horizontalScrollGesturesEnabled(boolean enabled)
26public NextbillionMapOptions tiltGesturesEnabled(boolean enabled)
27public NextbillionMapOptions zoomGesturesEnabled(boolean enabled)
28public NextbillionMapOptions doubleTapGesturesEnabled(boolean enabled)
29public NextbillionMapOptions quickZoomGesturesEnabled(boolean enabled)
31//Base Uri & Map tile
32public NextbillionMapOptions apiBaseUri(String apiBaseUri)
33public NextbillionMapOptions foregroundLoadColor(@ColorInt int loadColor)
34public NextbillionMapOptions setPrefetchesTiles(boolean enable)
35public NextbillionMapOptions setPrefetchZoomDelta(@IntRange(from = 0) int delta)
37//Glyphs and Font
38public NextbillionMapOptions localIdeographFontFamilyEnabled(boolean enabled)
39public NextbillionMapOptions localIdeographFontFamily(String fontFamily)
40public NextbillionMapOptions localIdeographFontFamily(String... fontFamilies)
Map View
SDK Interface