Navmii SDK v.2.0.x for Android

Navmii SDK v.2.0.x for Android

 

SDK Setup

Requirements

The SDK supports Android version 2.3.3 ("Gingerbread", API level 10) or higher and the following ABIs:

  • armeabi-v7a

  • arm64-v8a

  • x86

  • x86_64

Integrating the SDK

Adding the dependencies

In order to add the SDK library to your application insert the following code into your app's build.gradle:

repositories { maven { url '<url>' } } dependencies { compile ('com.navmii.android:navmiisdk:<sdk_version>@aar') }

Alternatively, if you have the AAR file, you can add it by using the following code:

 

repositories { flatDir { dirs '<the_path_to_navmiisdk_aar>' } } dependencies { compile (name: 'navmiisdk:<sdk_version>', ext: 'aar') }

Adding API Key to the Manifest

Add the following lines to the AndroidManifest.xml of your application within the <application></application> block:

<meta-data android:name="com.navmii.sdk.API_KEY" android:value="YOUR_API_KEY" />

Setting the permissions

Add the following lines to the AndroidManifest.xml within the <manifest></manifest> block:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The apps targeting Android 5.0 (API level 21) or higher must also include the following line:

<uses-feature android:name="android.hardware.location.gps" />

Limitations

This version of Navmii SDK doesn't support working with multiple instances of MapView at the same time. The SDK supports only one visible MapView instance at a time. Displaying multiple instances of MapView will result in an undefined behaviour.

Working with the SDK

The key component of the SDK is a singleton instance of  the Sdk class, which can be received with Sdk.getInstance() static method. To initialize the Sdk and start map rendering use the static Sdk.initSdkAsync method. This method takes ConfigurationSettings as an argument. To deinitialize the SDK use the Sdk.deinitializeSdk method. The Sdk.pause and Sdk.resume methods only start and stop map rendering respectively, without initializing/deinitializing the SDK.

To see code examples of initializing the SDK please refer to Creating the Map View section. ConfigurationSettings are described in SDK Configuration Settings.

Here's the most typical example of the last three methods usage:

@Override protected void onPause() { super.onPause(); Sdk.getInstance().pause(); } @Override protected void onResume() { super.onResume(); Sdk.getInstance().resume(); } @Override protected void onDestroy() { super.onDestroy(); if (Sdk.getInstance().getState() == Sdk.State.INITIALIZING || Sdk.getInstance().getState() == Sdk.State.INITIALIZED) { Sdk.getInstance().deinitializeSdk(); } }

 

SDK Configuration Settings

The ConfigurationSettings class represents the settings with which the SDK can be launched. If you have the resources designated to customize the map, you can specify the path to these resources via the setCustomResourcesPath method.

The SDK can use either online or offline map data, this can be selected via the setMapMode method. Call it with Sdk.ConfigurationSettings.MapMode.ONLINE or Sdk.ConfigurationSettings.MapMode.OFFLINE to use online or offline maps, respectively. When offline mode is selected, the path to the folder with maps has to be specified via the setOfflineMapsPath method.

You can also specify the path to the folder where the SDK puts files created at runtime.

To create a ConfigurationSettings instance use the ConfigurationSettings.Builder:

Sdk.ConfigurationSettings configurationSettings = new Sdk.ConfigurationSettings.Builder() .setOfflineMapsPath(thePath) .build();

Beta maps

When the SDK is configured to use online map data, it uses stable release maps by default. If you need more up-to-date map data, you can use Sdk.ConfigurationSettings.Builder.setUseOnlineBetaMaps(true) method to switch to beta maps. Please note that beta maps may contain errors which are not present in the release ones, therefore it's not recommended to use them in production.

If the SDK is configured to use offline map data, this method has no effect.

SDK State

The SDK can have four possible states represented by the Sdk.State enum:

  • UNINITIALIZED

  • INITIALIZING

  • INITIALIZED

  • INITIALIZATION_FAILED

The SDK can be used only when it's in INITIALIZED state. You can retrieve the current state through the Sdk.getState method.

The process of the SDK's initialization is asynchronous. To be informed on the initialization finish implement the StateChangeListener interface:

private class SdkStateListener implements Sdk.StateChangeListener { // Can only happen between onStart - onStop. @Override public void onStateChanged(Sdk.State state) { switch (state) { case UNINITIALIZED: break; case INITIALIZING: break; case INITIALIZED: break; case INITIALIZATION_FAILED: break; } } } private final Sdk.StateChangeListener stateChangeListener = new SdkStateListener(); @Override public void onStart() { super.onStart(); // Check - what if SDK initialization has failed between onStop - onStart. if (Sdk.getInstance().getState() == Sdk.State.INITIALIZATION_FAILED) { // Show an error message } Sdk.getInstance().addStateChangeListener(stateChangeListener);

Mapping

Map view

Creating the Map View

In order to add the map view to your activity, insert the following code into the layout file:

<com.navmii.sdk.map.MapView android:id="@+id/map_view" android:layout_width="match_parent" android:layout_height="match_parent" />

Then start the SDK with the Sdk.initSdkAsync static method and after successful initialization pass the map view to it using the setActiveMapView method. After MapView is no longer active you must call setActiveMapView(null).

@Override public void onStart() { super.onStart(); MapView mapView = (MapView) findViewById(R.id.map_view); if (Sdk.getInstance().getState() == Sdk.State.INITIALIZED) {  Sdk.getInstance().setActiveMapView(mapView); } } @Override public void onStop() { super.onStop(); if (Sdk.getInstance().getState() == Sdk.State.INITIALIZED) { Sdk.getInstance().setActiveMapView(null); } }

GPS Coordinates – Screen Position Transformation

You can transform Point representing a screen position of a point on the map to MapCoordinates object representing corresponding GPS location using MapView.getProjection method, which returns an instance of the MapProjection class, and the following code:

MapCoordinates coordinates = mapView.getProjection().mapCoordinatesFromScreenPosition(point);

The reverse operation can be performed by MapProjection.screenPositionFromMapCoordinates:

Point point = mapView.getProjection().screenPositionFromMapCoordinates(coordinates);

For example, to retrieve current GPS position relative to the screen, you can use the following code:

MapCoordinates coordinates = sdk.getNavigationManager().getCurrentPosition(); Point point = mapView.getProjection().screenPositionFromMapCoordinates(coordinates);

Note: south hemisphere latitudes are represented by negative values.

Working with Camera

Typically, you want to adjust the area presented on the map on your app's events. You can do it by using MapView.getCameraController method, which returns an instance of the CameraController class, that can be used to move camera to a desired position. The camera position itself is represented in Navmii SDK as CameraPositionCameraPosition and CameraController allow you to perform the following operations:

  • Setting map rotation via setHeading method

  • Setting map center via setTargetLocation method

  • Setting map zoom via setZoom method

  • Setting map tilt via setTilt method

The CameraPosition is instantiated with a builder:

CameraPosition cameraPosition = new CameraPosition.Builder(cameraController.getCameraPosition()) .setTilt(tilt) .setHeading(heading) .setZoom(zoom) .build();

To move the camera to a position without animation use the CameraController.moveCamera method:

mapView.getCameraController().moveCamera(cameraPosition);

Alternatively, you can set the desired camera position with animation, using one of the three overloaded animateCamera methods. The first one only takes the position. The second one allows you to provide a listener implementing the CameraAnimationListener interface, which will be notified when the animation ends. The last method additionally takes the duration parameter, allowing you to specify the duration of the animation. The default duration is 0.3 seconds.

// Sets the map camera's position with duration of 1.5 seconds // and logs the result when animation finishes or is canceled cameraController.animateCamera(cameraPosition, 1.5f, new MapView.CameraAnimationListener() { @Override public void onAnimationEnded(boolean isCompleted, boolean isCanceled) { Log.i("CameraAnimationListener", "onAnimationEnded"); } });

To stop current animation use the MapView.stopAnimation method:

mapView.stopAnimation();

Handling Camera Events

The SDK can inform you about camera movements, if you have a class implementing the CameraMovementListener interface and have added an instance of this class to CameraController object's listeners.

There can be three possible reasons for camera movement, defined in the CameraMovementReason enum:

  • gesture;

  • internal animation performed by the SDK (for example, during auto zoom);

  • animation requested by user (see Working with Camera for details).

// Adds ViewController to cameraController's listeners mapView.getCameraController().addCameraMovementListener(new MapView.CameraMovementListener() { @Override public void onCameraMoved(CameraMovementReason reason) { Log.i("CameraMovementListener", "onCameraMoved, reason: " + reason); } });

You also can add multiple listeners to a CameraController instance. To detach a listener use the removeCameraMovementListener method.

Map gestures

Gestures with Predefined Behaviour

After being created and added to the view hierarchy, MapView is ready to receive the user's touch events. The map reacts to the following gestures as described with no extra code needed.

  • Pan gesture. To drag the map, touch the screen with one finger and hold. Move the finger in the desired direction.

  • Swipe gesture. To move the map with inertia, swipe the screen with one finger. The map will proceed to move in the same direction for a period of time depending on the velocity of the gesture.

  • Pinch gesture. Touch the screen with two fingers and hold. Increase and decrease the distance between them to zoom in and zoom out respectively. Depending on the velocity of the gesture the map can have zoom inertia.

  • Rotation gesture. Touch the screen with two fingers and hold. Rotate the fingers relative to the screen. This gesture also has inertia behaviour.

  • Tilt gesture. Touch the screen with two fingers and move them simultaneously up or down to change the camera tilt.

If you want to handle these gestures in your code please refer to Handling Camera Events section.

Gestures without Predefined Behaviour

MapView recognizes the following gestures without a predefined behaviour. 

  • Single Tap Gesture. Tap the map with one finger once.

  • Double Tap Gesture. Tap the map with one finger twice.

  • Long Press Gesture. Touch the screen with one finger and hold for a period of time.

To process these gesture events make one your classes implement the MapTapListener interface and add it to MapView map tap listeners using the following code:

mapView.addMapTapListener(listener);

You can add multiple map tap listeners to a MapView instance.

This way your object or objects will be notified on these gesture events via the following methods:

@Override void onSingleTap(MapCoordinates coordinates) { // handle single tap } @Override void onDoubleTap(MapCoordinates coordinates) { // handle double tap } @Override void onLongTap(MapCoordinates coordinates) { // handle long tap }

Geo Items

Navmii SDK provides an easy way to present custom images on the map and to draw polylines. Children classes of GeoObject abstract class represent these custom images (GeoMarker) and polylines (GeoPolyline) in the SDK. MapView instance is responsible for creating and handling this type of objects.

Creating Markers on the Map

To present a marker on the map at specified coordinates with default image, instantiate it first by specifying its coordinates and the path to the image and then add it to the map using the MapView.addGeoObject method: 

GeoMarker marker = new GeoMarker(coordinates, imagePath); mapView.addGeoObject(marker);

Drawing Polylines

To draw a polyline on the map initialize, instantiate it with a list of MapCoordinates representing polyline vertices geo positions and then add it to the map:

GeoPolyline polyline = new GeoPolyline(coordinates); mapView.addGeoObject(polyline);

Working with Polylines

You can insert and remove a point or multiple points into and from a polyline, using GeoPolyline's addVertex, removeVertexremoveLastVertex and removeAllVertices methods. To retrieve overall vertices count use the getVertexCount method. To get a copy of all vertices, use the getVertices method.

// Adds a vertex to the polyline's end polyline.addVertex(coordinates); // Inserts a vertex into the polyline at index 3 if (polyline.getVertexCount() >= 3) { polyline.addVertex(3, coordinates); } // Removes last vertex from the polyline polyline.removeLastVertex(); // Removes the vertex at index 3 from the polyline if (polyline.getVertexCount() >= 3) { polyline.removeVertex(3); } // Removes all vertices from the polyline polyline.removeAllVertices();

The way the polyline is rendered on the map is also customizable. You can change the polyline's color and width using GeoPolyline's setColor and setWidth methods. The width property is a float value representing polyline's width in density-independent pixels (dp units).

// Sets polyline color to red polyline.setColor(Color.RED); // Sets polyline width to 3dp polyline.setWidth(3);

Interacting with Geo Objects

There are three types of user events related to GeoObject recognized by the SDK:

  • single tap on a geo object

  • double tap on a geo object

  • long press on a geo object

To be able to handle these events make one of your classes implement the GeoObjectListener interface and add an instance of this class to the map view's geo object listeners. Methods onGeoObjectClickonGeoObjectPressonGeoObjectRelease and onGeoObjectLongPress will be called on these events:

@Override void onGeoObjectClick(GeoObject geoObject) { // handle click } @Override void onGeoObjectPress(GeoObject geoObject) { // handle press } @Override void onGeoObjectRelease(GeoObject geoObject) { // handle release } @Override void onGeoObjectLongPress(GeoObject geoObject) { // handle long press }

 

Routing

Routes

The core component responsible for working with routes and navigation in Navmii SDK is RoutingManager. This class's singleton instance allows you to calculate and apply single and multiple routes and receive all necessary navigation information.

Calculating Routes

If you have a list of MapCoordinates representing waypoints for a route, you can calculate the route (and alternative routes, if applicable) using a RoutePlan instance and calculateRoute method. Alternatively, use calculateRouteFromCurrentPosition method if you you want the route to be calculated from the user's current GPS position. This way you don't need to pass the current position coordinates as the first element in the list of waypoints.

// Creates a RoutePlan instance with waypoints RoutePlan routePlan = new RoutePlan(); routePlan.setWaypoints(waypoints); // Calculates routes starting from the first coordinates in the array sdk.getRoutingManager().calculateRoute(routePlan); // Performs the same operation but starting with the user's current position sdk.getRoutingManager().calculateRouteFromCurrentPosition(routePlan);

The methods described above have overloads that accept a RoutingSettings instance as the second parameter. You can use them for customization of route calculation. For more information on RoutingSettings please refer to the Routing Settings section.

// Creates a RoutePlan instance with waypoints RoutePlan routePlan = new RoutePlan(); routePlan.setWaypoints(waypoints); // Creates a NMRoutingSettings instance with pedestrian routing mode RoutingSettings routingSettings = new RoutingSettings.Builder() .setRoutingMode(RoutingMode.PEDESTRIAN) .build(); // Applies the settings and calculates routes starting from the first coordinates in the array sdk.getRoutingManager().calculateRoute(routePlan, routingSettings); // Performs the same operation but starting with the user's current position sdk.getRoutingManager().calculateRouteFromCurrentPosition(routePlan, routingSettings);

Route Manager Status

There are three possible RouteManager states that can be obtained with the getStatus method:

  • No routes are presented on the map (NO_ROUTE)

  • A route (or routes) is presented on the map, but the navigation hasn't started (CHOOSING)

  • A route is applied and navigation is in process (ROUTE_APPLIED)

Handling Route Calculation Events

The SDK can notify listeners on the following route calculation events:

  • calculation started

  • calculation succeeded

  • calculation failed

  • route is cleared

To receive these notifications make one of your classes implement the RoutingListener interface and add it to RoutingManager listeners with the following code:

sdk.getRoutingManager().addRoutingListener(listener);

You can add multiple listeners to a RoutingManager instance, so you can have multiple objects notified on route calculation events. You can unsubscribe objects from these notifications using the removeRoutingListener method.

sdk.getRoutingManager().removeRoutingListener(listener);

Managing Calculated Routes

By default, the SDK calculates up to 3 routes with a particular route plan if possible and renders them on the map. You can disable this type of behaviour with the setDrawAlternativeRoutes method.

// Disables rendering of alternative routes on the map sdk.getRoutingManager().setDrawAlternativeRoutes(false);

The NSUInteger representing the number of all routes rendered on the map is stored in routesCount property, and the index of the currently selected route is stored in selectedRouteIndex property.

// Logs the numbers of routes and the selected route index

RoutingManager routingManager = sdk.getRoutingManager();

Log.i("RoutingManager", String.format("number of routes %s, selected route index %s", routingManager.getRouteCount(), routingManager.getSelectedRouteIndex()));

To select the route at the desired index use selectRouteAtIndex: method. The clearRoutes method removes all the calculated routes from the map. The abort method cancels route calculation that is currently in progress.

Routing Settings

Navmii SDK allows you to customize the parameters that will be used for route calculation via RoutingSettings. You can define if the traffic will be taken into consideration and if toll roads and motorways will be avoided on route calculation:

RoutingSettings routingSettings = new RoutingSettings.Builder() .setConsiderTraffic(true) .setAvoidTollRoads(true) .setAvoidMotorways(true) .build();

There are also parameters that define:

  • routing mode (pedestrian or vehicle)

  • optimization type (fastest, easiest, economical, shortest)

  • vehicle type (car, motorcycle, cycle, lorry, truck, delivery truck)

They can be set with setRoutingModesetRoutingOptimization and setVehicleType methods respectively.

RoutingSettings routingSettings = new RoutingSettings.Builder() .setRoutingMode(RoutingMode.VEHICLE) .setRoutingOptimization(RoutingOptimization.SHORTEST) .setVehicleType(VehicleType.TRUCK) .build();

Rerouting

When navigating on the route a better route can be calculated and the currently applied route changed. To enable/disable this option use the RoutingManager.setReroutingEnabled method. There are also two parameters you can specify defining when rerouting is triggered:

  • time difference with possible alternative route

  • length difference with possible alternative route

These parameters can be specified through the RoutingManager.setTimeThresholdForReroutingByTraffic and RoutingManager.setLengthThresholdForReroutingByTraffic methods respectively.

// Enables rerouting when a route 15 minutes faster or 10% shorter is calculated sdk.getRoutingManager().setReroutingEnabled(true); sdk.getRoutingManager().setTimeThresholdForReroutingByTraffic(15); sdk.getRoutingManager().setLengthThresholdForReroutingByTraffic(10);

If you have added a RoutingListener to the RoutingManager, it will be notified on rerouting through onRouteCalculationSucceeded method. In this case the calculationReason parameter will be either REROUTING or REROUTING_CAUSED_BY_TRAFFIC.

Navigation

Navigation Manager

The main component responsible for navigation in Navmii SDK is NavigationManager. You can access an instance of this class via Sdk.getNavigationManager method:

NavigationManager navigationManager = sdk.getNavigationManager();

Navmii SDK generates various navigation events. To be able to handle these events make one of your classes implement the NavigationListener interface and add an instance of this class to NavigationManager listeners via addNavigationListener method:

navigationManager.addNavigationListener(listener);

You also can add multiple listeners to NavigationManager instance. To detach a listener from NavigationManager instance use removeNavigationListener method.

These navigation events are:

  • change of GPS status

  • change of iOS location services authorization status

  • change of current position

  • update of navigation information (see Navigation Info section)

  • change of country of current location

  • update of guidance info (see Guidance)

  • passing a waypoint

  • reaching the destination

  • demo route start

  • demo route stop

"Passing a waypoint" and "reaching the destination" events correspond to onWaypointPassed and onArrivalPointReached methods respectively:

@Override void onWaypointPassed() { Log.i("NavigationListener", "onWaypointPassed"); } @Override void onArrivalPointReached() { Log.i("NavigationListener", "onArrivalPointReached"); }

GPS Status

The NavigationManager has the getGpsStatus method indicating if the SDK accepts GPS signal. GPS status is represented as GpsStatus enum of the following values:

  • OK

  • NO_SIGNAL

  • OFF

The onGpsStatusChanged event in NavigationListener interface will be triggered when the status changes:

@Override public void onGpsStatusChanged(GpsStatus status) { Log.i("NavigationListener", "onGpsStatusChanged " + status); }

Retrieving Current Position

The user's current position can be retrieved via NavigationManager.getCurrentPosition method. 

// Logs the user's current position MapCoordinates currentPosition = navigationManager.getCurrentPosition(); Log.i("NavigationManager", "You are at coordinates: " + currentPosition);

The NMNavigationService listeners will be informed on current position change via onCurrentPositionChanged: method:

@Override public void onCurrentPositionChanged(MapCoordinates coordinates) { Log.i("NavigationListener", "onCurrentPositionChanged: " + coordinates); }

Demo Route

Navmii SDK allows you to demonstrate the way the real-time traverse of the route will look like on the screen. When the route is calculated, use startDemoRoute and stopDemoRoute methods. Use isDemoRouteActive method to find out if the demo route is still in progress.

// Starts demo route navigationManager.startDemoRoute(); // Stops demo route navigationManager.stopDemoRoute();

This is an example of handling demo route start and finish in NavigationListener interface implementation:

// Logs out messages on demo route start and finish @Override public void onDemoRouteStarted() { Log.i("NavigationListener", "onDemoRouteStarted"); } @Override public void onDemoRouteFinished() { Log.i("NavigationListener", "onDemoRouteFinished"); }

Traffic on Route Image

Navmii SDK also creates a bitmap image representing traffic on the current route. To be able to receive this image when it updates, make one of you classes implement the TrafficOnRouteImageListener interface and add an instance of this class to NavigationManager's "traffic on route image" listeners:

navigationManager.addTrafficOnRouteImageListener(listener);

To detach a "traffic on route image" listener use removeTrafficOnRouteImageListener method.

@Override void onTrafficOnRouteImageUpdated(Bitmap bitmap) { // handle the image }

Navigation Info

When navigating on the route you can get a NavigationInfo instance from NavigationManager. This object will contain the following information:

  • current road information

  • next road information

  • next direction

  • distance to the next direction in meters

  • speed limit in km/h

  • user's current speed in km/h

  • time to destination point in seconds

  • distance to destination point in meters

  • passed distance in meters

  • country information

  • distance to the next speed camera in meters

To understand how road information is presented in the SDK please refer to Road Info section. Here is an example of code giving you the idea how to retrieve this information:

NavigationInfo navigationInfo = navigationManager.getNavigationInfo(); Log.i("NavigationInfo", String.format("current road name - %s", navigationInfo.getCurrentRoad().getName())); Log.i("NavigationInfo", String.format("next direction type - %s", navigationInfo.getNextDirection().getDirectionType())); Log.i("NavigationInfo", String.format("distance to the next direction - %s meters", navigationInfo.getDistanceToDirection())); Log.i("NavigationInfo", String.format("speed limit - %s kmh", navigationInfo.getSpeedLimit())); Log.i("NavigationInfo", String.format("current speed - %s kmh", navigationInfo.getCurrentSpeed())); Log.i("NavigationInfo", String.format("time to destination - %s seconds", navigationInfo.getTimeToDestination())); Log.i("NavigationInfo", String.format("distance to destination - %s meters", navigationInfo.getDistanceToDestination())); Log.i("NavigationInfo", String.format("passed distance - %s meters", navigationInfo.getPassedDistance())); Log.i("NavigationInfo", String.format("country - %s", navigationInfo.getCountry().getName())); Log.i("NavigationInfo", String.format("distance to speed camera - %s", navigationInfo.getDistanceToSpeedCamera()));

 

Road Info

 A RoadInfo instance contains the following information on a road:

  • road name

  • route number

  • form of way

  • functional class

Form of way is represented as FormOfWay enum with this set of values:

  • COMMON

  • RAMP

  • ROUNDABOUT

  • FERRY

An example of code extracting this information from RoadInfo instance can look like this:

RoadInfo roadInfo = navigationInfo.getCurrentRoad(); Log.i("NavigationInfo", String.format("road name - %s", roadInfo.getName())); Log.i("NavigationInfo", String.format("route number - %s", roadInfo.getRouteNumber())); Log.i("NavigationInfo", String.format("form of way - %s", roadInfo.getFormOfWay())); Log.i("NavigationInfo", String.format("functional class - %s", roadInfo.getFunctionalClass()));

Guidance

Navmii SDK allows you to setup the way the navigation guidance will be provided. It's possible throughout the NavigationManager.getGuidanceSettings method. You can set the guidance output either to text or switch it off. If you pass GuidanceOutput.TEXT to the GuidanceSettings.setGuidanceOutput method, you'll be able to receive String instances with navigation guidance in NavigationListener.onGuidanceTextReady method.

@Override public void onGuidanceTextReady(String text) { Log.i("NavigationListener", "onGuidanceTextReady: " + text); }

 

You can also set guidance language via the GuidanceSettings.setLocale method. To get the list of all languages supported by the SDK use the getSupportedLocales method.

// Sets guidance language to American English GuidanceSettings settings = navigationManager.getGuidanceSettings(); settings.setLocale("en-US");

 

Currently supported languages:

  • Czech

  • Danish

  • English (UK)

  • English (US)

  • Finnish

  • French (France)

  • German

  • Italian

  • Korean

  • Norwegian

  • Polish

  • Portugese (Brazil)

  • Portugese (Portugal)

  • Russian

  • Spanish (Spain)

  • Swedish

  • Turkish

Places and coordinates

Coordinates

Geo locations in Navmii SDK are represented as instances of the read-only MapCoordinates class. As expected, it has two methods: getLatitude (returns values in the range [-90, 90]) and getLongitude (returns values in the range [-180, 180)). If the values passed to the constructor of MapCoordinates are out of their ranges, they will be adjusted automatically:

  • the latitude is clamped to the range [-90, 90] (e.g. 120 will become 90)

  • the longitude is normalized to the range [-180, 180) (e.g. 195 will become -165)

Navmii SDK also has the MapRectangle class representing a rectangle area on the map. It can be created either by specifying its top left and bottom right corners or by using the MapRectangle.boundingRectangle method. The latter creates a MapRectangle surrounding all the coordinates passed as the argument.