Skip to main content

Getting started

Contents

With the Mobile Maps SDK, you can embed interactive, highly customizable maps into your Android mobile applications. Our maps are built on commercial vehicle-specific data from Trimble Maps, which allows you to plan and visualize safe, legal, and efficient routes for all types of vehicles, around the world. With features ranging from traffic data to weather alerts and road conditions, our Maps SDK is ideal for any application that demands maps for work.

To gain access to the SDK, please contact our Sales team for more information.

This guide is intended to get you on your way to incorporating Trimble’s mapping library into your mobile project. It covers the key concepts needed to install, display, and customize maps. You can also view sample projects and code in our public GitHub repository.

mobile maps screenshot

Installation

In order to use the Maps SDK, you will need to add it as a dependency to your project. The library can be accessed from a Maven repository. To add the dependency, configure your build to download the Maps SDK:

  1. Open your project in Android Studio
  2. Open up your project-level settings.gradle file (settings.gradle.kts file in Kotlin)
  3. Declare the Trimble Maps repository in the repositories block:
  1. Open up your module-level build.gradle file
  2. Ensure your project’s minSdkVersion is at API 14 or later
  3. Under dependencies, add a new build rule for the latest SDK:
dependencies {
    implementation("com.trimblemaps.mapsdk:maps-android-sdk:1.3.0")
    implementation("com.trimblemaps.mapsdk:maps-sdk-services:1.3.0")
}
  1. Complete a Gradle sync

Permissions

You can use the Manifest merge feature to reduce the need to include any SDK requirements in your application’s manifest file. You’ll need to add either the Fine or Coarse location permission to your manifest if you plan to display a user’s location on the map or get the user’s location information, and the Background location permission to continue it while the app is in the background.

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

The user’s location permission should be checked during runtime using the PermissionsManager.

Android provides a guide to requesting permissions from users as well as details on location access.

Authentication

In order to use the APIs and SDK, you will need to authenticate your API key first. If you do not have an API key, you can request one. Authentication must be done prior to attempting to render a MapView or using the APIs. An example can be found below:

Once authentication is complete, you can start to use the SDK. To see authentication in conjunction with displaying a map, see Displaying a basic map.

Connecting to a proxy server (optional)

Prior to initializing the session, you can create a connection to a proxy server and pass it into the initialize function. The code below demonstrates how to set up a proxy.

Displaying a basic map

To add a map to your application, the Maps SDK provides the MapView class. This provides out-of-the-box capability to display a map with street names, road information etc. Additionally, the map can be styled, moved, rotated etc.

Interaction with the map itself is done through the TrimbleMapsMap object. This can be retrieved using the getMapAsync() method on the MapView.

For a full example, please see the Basic Map example code.

Android activity lifecycle methods

Android activity lifecycle methods should be implemented to ensure the app adheres to Android’s lifecycle. See below:

Last updated June 28, 2024.
Contents