Skip to main content

Frame Locations

Contents

The Mobile Maps SDK examples require that you first complete the initial project set-up.

Frame the map view to the bounds of a set of locations. In this case, we will use the Lines On a Map example to frame the map to each set of lines when clicking on the buttons, which will utilize the moveCamera() or easeCamera() functions.

activity_sample_framing.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.trimblemaps.mapsdk.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/btn_cycleLocations"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="moveCamera()"
            android:textAllCaps="false" />

        <Button
            android:id="@+id/btn_easeCamera"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="easeCamera()"
            android:textAllCaps="false" />
    </LinearLayout>
</LinearLayout>

Sample Code

Before running the Java or Kotlin code, the theme needs to be set in the Theme.xml file as shown below.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.AsyncAcctInit" parent="Theme.AppCompat" />
</resources>
Last updated January 16, 2025.
Contents