Fly To Coordinates
In this guide you will learn how to insert a landmark into the favorites, and also how to remove a landmark from the favorites.
Setup
- Get your Magic Lane API key token: if you do not have a 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.

The heart icon shows that the landmark is added to the favorites when it is filled, and not added to the favorites when it is just a contour.
How it works
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.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
gemSurfaceView = findViewById(R.id.gem_surface)
SdkSettings.onMapDataReady = onMapDataReady@{ isReady ->
if (!isReady) return@onMapDataReady
SdkCall.execute {
// Defines an action that should be done after the world map is ready.
flyTo(Coordinates(2.33412, 48.86144)) //pyramide inversee, Louvre, Paris
}
}
if (!Util.isInternetConnected(this)) {
Toast.makeText(this, "You must be connected to internet!",
Toast.LENGTH_LONG).show()
}
}
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.
private fun flyTo(coordinates: Coordinates) = SdkCall.execute {
// Center the map on a specific set of coordinates using the provided animation.
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.