THIS SDK ISDEPRECATED.

We rolled out a new and better SDK for you.

Map initialization

The Maps SDK for Android allows you to initialize the map with a setup configuration. For this purpose, use the MapFragment.newInstance() method or MapView constructor with MapProperties. The MapProperties object allows you to set initial map values of the map.

Initializing the map with bounding box

Programmatically:

1val amsterdamTopLeft = LatLng(52.499782, 4.749553)
2val amsterdamBottomRight = LatLng(52.246161, 5.031764)
3val boundingBox = BoundingBox(amsterdamTopLeft, amsterdamBottomRight)
4val focusArea: CameraFocusArea = CameraFocusArea.Builder(boundingBox)
5 .pitch(5.0)
6 .bearing(MapConstants.ORIENTATION_NORTH.toDouble())
7 .build()
8val apiKeys = mapOf(ApiKeyType.MAPS_API_KEY to BuildConfig.MAPS_API_KEY)
9val mapProperties = MapProperties.Builder()
10 .cameraFocusArea(focusArea)
11 .keys(apiKeys)
12 .build()
13mapFragment = MapFragment.newInstance(mapProperties)

From XML:

1<com.tomtom.online.sdk.map.MapView
2 android:id="@+id/map_view"
3 android:name="com.tomtom.online.sdk.map.MapFragment"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 app:cameraFocusAreaTopLeftLatitude="52.499782"
7 app:cameraFocusAreaTopLeftLongitude="4.749553"
8 app:cameraFocusAreaBottomRightLatitude="52.246161"
9 app:cameraFocusAreaBottomRightLongitude="5.031764"
10 app:cameraFocusAreaPitch="5.0"
11 app:cameraFocusAreaBearing="0.0" />

Centering the map with starting point

Programmatically:

1val tomtomOfficeLodz = LatLng(51.759434, 19.449011)
2val cameraPosition = CameraPosition.builder()
3 .focusPosition(tomtomOfficeLodz)
4 .zoom(MapConstants.DEFAULT_ZOOM_LEVEL)
5 .pitch(5.0)
6 .bearing(MapConstants.ORIENTATION_NORTH.toDouble())
7 .build()
8val apiKeys = mapOf(ApiKeyType.MAPS_API_KEY to BuildConfig.MAPS_API_KEY)
9val mapProperties = MapProperties.Builder()
10 .cameraPosition(cameraPosition)
11 .keys(apiKeys)
12 .build()
13mapFragment = MapFragment.newInstance(mapProperties)

From XML:

1<fragment
2 android:id="@+id/map_fragment"
3 android:name="com.tomtom.online.sdk.map.MapFragment"
4 android:layout_width="match_parent"
5 android:layout_height="match_parent"
6 app:cameraPositionLatitude="52.499782"
7 app:cameraPositionLongitude="4.749553"
8 app:cameraPositionZoom="14.0"
9 app:cameraPositionPitch="5.0"
10 app:cameraPositionBearing="0.0" />

image

Map initialized on Lodz Office of TomTom with 15 zoom level

image

Map initialized on Amsterdam area