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.
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
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.
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.
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.
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.
Available listeners:
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.
- 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.
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.
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.