• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

SDK Interface

NextbillionMap is an interactable interface of the MapView, each MapView instance will have one associated instance of NextbillionMap.

We can get the reference of NextbillionMap that belongs to a current MapView in the callback of OnMapReadyCallback.

With NextbillionMap we can make changes to the current MapView, which includes:

  • Get basic information about the current MapView
  • Scroll the current MapView
  • Style management
  • Perform camera control
  • Annotations management
  • Manage multiple gesture listeners
  • Manage InfoWindow
  • Query rendered features
  • Obtain reference of UiSettings
  • Obtain reference of Projection

With NextbillionMap, developers have a comprehensive solution for adding location intelligence and mapping capabilities to their Android mobile applications.

Interface

The NextbillionMap Interface is a powerful tool for developers to integrate maps and location services into their Android mobile applications. It provides a user-friendly interface and a wide range of features. The SDK is designed to be highly customizable, allowing developers to create unique and interactive mapping experiences for their users. With the NextbillionMap Android Map SDK, developers can add location intelligence and mapping capabilities to their apps, enabling users to explore, discover and interact with the world around them in new and innovative ways.

Get basic information about the current MapView

The getHeight() and getWidth() methods in the NextbillionMap Android Map SDK Interface provide basic information about the current MapView by returning its height and width respectively. The height and width of a MapView are returned as floating-point values, indicating the dimensions of the view in device-independent pixels.

1public float getHeight()
2public float getWidth()

By calling these methods, developers can retrieve the current dimensions of the MapView, which can be useful for various purposes such as adjusting the display of annotations or other elements within the map. For example, a developer could use the MapView's height and width to determine the ideal size for markers or other visual elements on the map, ensuring that they are displayed optimally on any screen size.

Scroll the current MapView

1public void scrollBy(float x, float y)
2public void scrollBy(float x, float y, long duration)

The scrollBy(float x, float y) and scrollBy(float x, float y, long duration) methods in the NextbillionMap Android Map SDK Interface allow developers to control the movement of the MapView. These methods scroll the MapView by a specified distance in the x and y directions and offer a choice between an immediate scroll or a smooth animated scroll with a specified duration. This allows developers to easily navigate the MapView programmatically and create an interactive mapping experience for the user.

Style management

The NextbillionMap Android Map SDK Interface provides several methods for managing the style of the MapView, including retrieving, setting, and updating the style as needed.

1public Style getStyle()
2public void getStyle(@NonNull Style.OnStyleLoaded onStyleLoaded)
3public void setStyle(String style)
4public void setStyle(String style, final Style.OnStyleLoaded callback)
5public void setStyle(Style.Builder builder)
6public void setStyle(Style.Builder builder, final Style.OnStyleLoaded callback)

The getStyle() method returns the current style of the MapView. This method can be useful for retrieving the current style for further processing or for storing it for later use. For more advanced style management, the getStyle(@NonNull Style.OnStyleLoaded onStyleLoaded) method allows developers to retrieve the style of the MapView asynchronously, providing a callback to handle the loaded style.

The setStyle(String style) and setStyle(String style, final Style.OnStyleLoaded callback) methods allow developers to set the style of the MapView using a JSON string that defines the style. The second method provides a callback to handle the loaded style. In addition, the setStyle(Style.Builder builder) and setStyle(Style.Builder builder, final Style.OnStyleLoaded callback) methods allow developers to programmatically build and set the style of the MapView using the Style.Builder class. The second method provides a callback to handle the loaded style.

In summary, the style management methods in the NextbillionMap Android Map SDK Interface provide a comprehensive solution for customizing the appearance of the MapView and for working with the styles of the map. These methods allow developers to easily retrieve, set, and update the styles of the MapView, providing a flexible and powerful way to control the look and feel of the map.

For more details of Style, please refer to SDK Style and GeoJSON.

Perform camera control

This code provides functionality for controlling the camera in a map view. The methods allow you to set the camera position, set a LatLngBounds or Geometry to focus on, and retrieve the current camera position. There are also methods to add or remove listeners for camera movement events, such as onCameraIdle, onCameraMoveStarted, onCameraMoveCanceled, and onCameraMove.

1public void setLatLngBoundsForCameraTarget(@Nullable LatLngBounds latLngBounds)
2public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds)
3public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds,
4 @NonNull @Size(value = 4) int[] padding)
5public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds,
6 @FloatRange(from = NbmapConstants.MINIMUM_DIRECTION,
7 to = NbmapConstants.MAXIMUM_DIRECTION) double bearing,
8 @FloatRange(from = NbmapConstants.MINIMUM_TILT,
9 to = NbmapConstants.MAXIMUM_TILT) double tilt)
10public CameraPosition getCameraForLatLngBounds(@NonNull LatLngBounds latLngBounds,
11 @NonNull @Size(value = 4) int[] padding,
12 @FloatRange(from = NbmapConstants.MINIMUM_DIRECTION,
13 to = NbmapConstants.MAXIMUM_DIRECTION) double bearing,
14 @FloatRange(from = NbmapConstants.MINIMUM_TILT,
15 to = NbmapConstants.MAXIMUM_TILT) double tilt)
16public CameraPosition getCameraForGeometry(@NonNull Geometry geometry)
17public CameraPosition getCameraForGeometry(@NonNull Geometry geometry,
18 @NonNull @Size(value = 4) int[] padding)

Annotations management

These are the functions provided by an annotations management system in a mapping application. The functions add a marker, polyline, or polygon to the map. The functions update a marker, polyline, or polygon that is already on the map. The functions remove a marker, polyline, or polygon, or remove all annotations from the map. The functions get annotations, markers, polylines, and polygons that are on the map.

1public Marker addMarker(@NonNull LatLng position)
2public Marker addMarker(@NonNull MarkerOptions markerOptions)
3public Marker addMarker(@NonNull BaseMarkerOptions markerOptions)
4public List<Marker> addMarkers(@NonNull List<? extends
5 BaseMarkerOptions> markerOptionsList)
6public void updateMarker(@NonNull Marker updatedMarker)
7public Polyline addPolyline(@NonNull LatLng origin, @NonNull LatLng dest, int color)
8public Polyline addPolyline(@NonNull LatLng origin, @NonNull LatLng dest, String color)
9public Polyline addPolyline(@NonNull List<LatLng> points, int color)
10public Polyline addPolyline(@NonNull List<LatLng> points, String color)
11public Polyline addPolyline(@NonNull PolylineOptions polylineOptions)
12public List<Polyline> addPolylines(@NonNull List<PolylineOptions> polylineOptionsList)
13public void updatePolyline(@NonNull Polyline polyline)
14public Polygon addPolygon(@NonNull List<LatLng> points, int color)
15public Polygon addPolygon(@NonNull List<LatLng> points, String color)
16public Polygon addPolygon(@NonNull PolygonOptions polygonOptions)
17public List<Polygon> addPolygons(@NonNull List<PolygonOptions> polygonOptionsList)
18public void updatePolygon(@NonNull Polygon polygon)

The setOnMarkerClickListener, setOnPolygonClickListener, and setOnPolylineClickListener functions allow setting listeners for clicks on markers, polylines, or polygons. The selectMarker and deselectMarker functions allow for selecting and deselecting markers. The getSelectedMarkers function returns the list of selected markers.

For more details of annotations, please refer to Markers and Annotations.

Manage gesture listeners

These are methods for adding and removing listeners for different types of gestures in an application.

1public void addOnFlingListener(@NonNull OnFlingListener listener)
2public void removeOnFlingListener(@NonNull OnFlingListener listener)
3public void addOnMoveListener(@NonNull OnMoveListener listener)
4public void removeOnMoveListener(@NonNull OnMoveListener listener)
5public void addOnRotateListener(@NonNull OnRotateListener listener)
6public void removeOnRotateListener(@NonNull OnRotateListener listener)
7public void addOnScaleListener(@NonNull OnScaleListener listener)
8public void removeOnScaleListener(@NonNull OnScaleListener listener)
9public void addOnShoveListener(@NonNull OnShoveListener listener)
10public void removeOnShoveListener(@NonNull OnShoveListener listener)
11public void addOnMapClickListener(@NonNull OnMapClickListener listener)
12public void removeOnMapClickListener(@NonNull OnMapClickListener listener)
13public void addOnMapLongClickListener(@NonNull OnMapLongClickListener listener)

Available listeners:

1OnFlingListener
2OnMoveListener
3OnRotateListener
4OnScaleListener
5OnShoveListener
6OnCameraMoveStartedListener
7OnCameraMoveListener
8OnCameraMoveCanceledListener
9OnCameraIdleListener
10OnCompassAnimationListener
11OnFpsChangedListener
12OnGesturesManagerInteractionListener
13OnMapClickListener
14OnMapLongClickListener
15OnMarkerClickListener
16OnPolygonClickListener
17OnPolylineClickListener
18OnInfoWindowClickListener

For more details of gestures, please refer to UI Settings and Gestures.

Manage InfoWindow

These methods are for managing an InfoWindow in a map application. An InfoWindow is a pop-up window that provides information about a specific location or feature on a map.

1public void setOnInfoWindowClickListener(@Nullable OnInfoWindowClickListener listener)
2public OnInfoWindowClickListener getOnInfoWindowClickListener()
3public void setOnInfoWindowLongClickListener(@Nullable OnInfoWindowLongClickListener)
4public OnInfoWindowLongClickListener getOnInfoWindowLongClickListener()
5public void setOnInfoWindowCloseListener(@Nullable OnInfoWindowCloseListener listener)
6public OnInfoWindowCloseListener getOnInfoWindowCloseListener()
  • setOnInfoWindowClickListener: sets a listener to receive notifications when an InfoWindow is clicked.
  • getOnInfoWindowClickListener: returns the current InfoWindow click listener.
  • setOnInfoWindowLongClickListener: sets a listener to receive notifications when an InfoWindow is long-clicked.
  • getOnInfoWindowLongClickListener: returns the current InfoWindow long-click listener.
  • setOnInfoWindowCloseListener: sets a listener to receive notifications when an InfoWindow is closed.
  • getOnInfoWindowCloseListener: returns the current InfoWindow close listener.

Query rendered features

These methods are for querying the features that have been rendered on a map. A feature is a geometric shape (such as a point, line, or polygon) that represents a real-world object or location.

The methods take the following parameters:

  • coordinates: the location to query, either a point or a rectangle
  • filter: an optional expression used to filter the features based on their properties
  • layerIds: an optional list of layer IDs to restrict the query to

The methods return a list of Feature objects that have been rendered on the map and match the specified criteria.

1public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates, @Nullable String... layerIds)
2public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
3 @Nullable Expression filter,
4 @Nullable String... layerIds)
5public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates, @Nullable String... layerIds)
6public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
7 @Nullable Expression filter,
8 @Nullable String... layerIds)

The first two methods query features based on a point location. The second two methods query features based on a rectangular area. The difference between the two sets of methods is whether a filter expression is specified or not. If a filter is specified, only features that match the filter criteria will be returned. If no filter is specified, all features that have been rendered within the specified location will be returned.

Obtain reference of UiSettings

This method is for obtaining a reference to the UiSettings object associated with a map. The UiSettings object provides control over various user interface elements of the map, such as the zoom controls, the compass, and the my-location button.

1public UiSettings getUiSettings()

By calling getUiSettings(), you can access the UiSettings object and use its methods to modify the behavior and appearance of the map's user interface elements.

For more details of UiSettings please refer to UI Settings and Gestures.