Skip to content

Fly To Coordinates

In this guide you will learn how to render an interactive map, and fly to a destination specified by (longitude, latitude) coordinates.


First, get an API key token, see the Getting Started guide.

Download the Maps & Navigation SDK for Android archive file

Download the FlyToCoordinates project archive file or clone the project with Git

See the Configure Android Example guide.

Run the example

In Android Studio, from the File menu, select Sync Project with Gradle Files

An android device should be connected via USB cable.
Press SHIFT+F10 to compile, install and run the example on the android device.

Fly to coordinates example Android screenshot

This example flies to the destination specified by the given latitude, longitude point coordinates.
Displays an interactive map which is fully 3D, supporting pan, pinch-zoom, rotate and tilt.

How it works

Android example screenshot

You can open the MainActivity.kt file and edit the coordinates of the destination (latitude, longitude) as shown in the code below, and run the app again to fly to a different destination.

 1override fun onCreate(savedInstanceState: Bundle?) {
 2     super.onCreate(savedInstanceState)
 3     setContentView(R.layout.activity_main)
 4     gemSurfaceView = findViewById(
 5     SdkSettings.onMapDataReady = onMapDataReady@{ isReady ->
 6         if (!isReady) return@onMapDataReady
 7         SdkCall.execute {
 8             // Defines an action that should be done after the world map is ready.
 9             flyTo(Coordinates(2.33412, 48.86144)) //pyramide inversee, Louvre, Paris
10         }
11     }
12     if (!Util.isInternetConnected(this)) {
13         Toast.makeText(this, "You must be connected to internet!",
14             Toast.LENGTH_LONG).show()
15     }
MainActivity overrides the onCreate() function which checks that internet access is available, and then, when the map is initialized and ready, flies the camera to the specified hardcoded coordinates.
1private fun flyTo(coordinates: Coordinates) = SdkCall.execute {
2     // Center the map on a specific set of coordinates using the provided animation.
3     gemSurfaceView.mapView?.centerOnCoordinates(coordinates)
The flyTo() function is implemented using
gemSurfaceView.mapView?.centerOnCoordinates(coordinates), where the coordinates are given as longitude, latitude in degrees.
For example, you can change the Coordinates to (45.43597, 12.33060) to fly to Venice instead of Louvre, and then run the example again.

Android Examples

Maps SDK for Android Examples can be downloaded or cloned with Git