Skip to main content
GuidesAPI ReferenceExamples

Hello Map

|

In this example you will learn how to render an interactive map centered on a desired location. The map is fully 3D, supporting pan, pinch-zoom, rotate and tilt.

Map View

Map Display and Cleanup

The following code outlines the main activity, which displays the map and handles resource clean-up.

The MainActivity overrides the onCreate function which instantiates and loads the map: setContentView(R.layout.activity_main) as defined in res/layout/activity_main.xml.

MainActivity.kt
class MainActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?)
{
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}

override fun onDestroy()
{
super.onDestroy()

// Release the SDK.
GemSdk.release()
}

}

The com.magiclane.sdk.core.GemSurfaceView is a custom View that displays the map, part of Magic Lane's SDK.

MainActivity.kt
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.magiclane.sdk.core.GemSurfaceView
android:id="@+id/gem_surface"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</androidx.constraintlayout.widget.ConstraintLayout>