Skip to content

Kotlin Tutorial App

In this guide you will learn how to use various features of the Magic Lane Maps API for Kotlin, such as maps, search, fly to a location, routing, downloading maps for offline use and setting a custom server.

Example App Guide

Android example 3D map screenshot

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

Download the Maps & Navigation SDK for Android archive file

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

Extract/unzip TutorialAppKotlin.zip to a folder/directory of your choice. You can create a new directory where to unzip it.
Extract the Maps SDK for Android. This will create a new directory/folder containing a file with the .aar extension.
Copy or move the Maps SDK for Android .aar file to the TutorialAppKotlin/app/libs/ directory.
Android Studio should be installed to continue.Android Studio welcome dialog
Start Android Studio, and in the welcome dialog, choose Open an Existing Project.
Android Studio open project dialog
Select the TutorialAppKotlin directory and click OK.
Android SDK change dialog

A dialog may appear, informing you that the Android SDK you have will be used.

AndroidManifest.xml

On the left margin, doubleclick Project, then app->manifests->AndroidManifest.xml

Set your API key token
In AndroidManifest.xml, replace YOUR_TOKEN with your actual API key token copied above.
Android studio sync gradle
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.

Kotlin Example App Overview

TutorialAppKotlin demonstrates how to perform a search, download a map, change the map style, make a route from point A to point B and more.

Maps

  • To change the map style select Styles in the left top corner menu.

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

Android example map style screenshot

There are many options such as satellite imagery, 3D terrain topography, day or night

Android example one map view screenshot

Android example two map views screenshot

Android example map style screenshot

  • One map view (the map fills the entire screen)

  • Two tiled map views (2 maps, each covering half of the screen)

  • Two overlapped map views (2 maps, one covering the whole screen and one or more smaller inset map(s))

Routing

Android example menu screenshot
  • A to B route (a route from A to B is rendered on the map)

  • A to B via C route (a route via a specified intermediate waypoint)

Android example route start screenshot

To calculate and render a route on the map, select Route - Custom in the left top corner menu.

Pan and zoom the map to select a starting position, by placing the center icon on it, then click the green icon in the lower right corner of the screen

Android example route destination screenshot

Pan and zoom the map to select a destination position, then click the red icon in the lower right corner of the screen

Android example route screenshot

A route is calculated and rendered in blue on the map

Offline Maps

Android example map download screenshot
  • Download maps for offline use, including routing and navigation, without an internet connection (maps are available for any country, or just regions of a country for some countries)

Select Online Maps in the left top corner menu; to quickly find a given country, type one or more letters in the search box at the top

Fly to

  • Fly to landmark (shows a certain location on the map and details about the specific location. If the location has a Wikipedia page, you can see Wikipedia images for it, read the description of the location and access the Wikipedia page)

  • Fly to area (shows a certain area on the map and details about it. If the area has a Wikipedia page, you can see Wikipedia images for it, read the description of the area and access the Wikipedia page)

  • Fly to route (shows a route on the map and you can simulate navigation along it or see the route instructions)

  • Fly to route instructions (shows a route on the map and you can see the next move you should make as an image and as text instruction in a black panel on the top of your screen e.g. “Leave the roundabout at the 1st exit”, including the distance to the next move)

  • Fly to traffic (shows on the map an area that has heavy traffic and you are informed in a black panel on the top of your screen that you are queuing traffic for a distance/ period of time e.g. “1 min, 1.3 km, Queuing traffic”)

Server

  • Set a custom server (you can choose to use a custom server)

Android Examples

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