Migration Guide
Mappedin SDK for Android version 6.0 is a major release that includes a number of changes to the SDK. It uses a GeoJSON-based rendering engine, rebuilt from the ground up. It works in unison with MapLibre which enables outdoor base maps as well as data visualization features. By using GeoJSON as the core data format, v6 can integrate with existing external data sources. This guide explains the steps needed to migrate from version 5.
Initialization Changes
The options for getting a map have changed. getVenue() has been replaced by getMapData().
v5 Initialization
// See Trial API key Terms and Conditions
// https://developer.mappedin.com/api-keys/
mapView.loadVenue(
MPIOptions.Init(
"5eab30aa91b055001a68e996",
"RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
"mappedin-demo-mall",
),
MPIOptions.ShowVenue(
shadingAndOutlines = true,
multiBufferRendering = true,
outdoorView = MPIOptions.OutdoorView(enabled = true),
),
) { Log.e(javaClass.simpleName, "Error loading map view") }
v6 Initialization
// See Trial API key Terms and Conditions
// https://developer.mappedin.com/docs/demo-keys-and-maps
val options =
GetMapDataWithCredentialsOptions(
key = "5eab30aa91b055001a68e996",
secret = "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
mapId = "mappedin-demo-mall",
)
// Load the map data.
mapView.getMapData(options) { result ->
result
.onSuccess {
Log.d("MappedinDemo", "getMapData success")
// Display the map.
mapView.show3dMap(Show3DMapOptions()) { r ->
r.onSuccess {
Log.d("MappedinDemo", "show3dMap success")
}
r.onFailure {
Log.e("MappedinDemo", "show3dMap error: $it")
}
}
}.onFailure {
Log.e("MappedinDemo", "getMapData error: $it")
}
}
Component Access
MPIData.<collection> has been replaced by MapData.getByType(<collection>)
For example:
In v5 access nodes using MPIData.nodes, which contains an array of Node objects.
In v6 access nodes using mapData.getByType<Node>(MapDataType.Node), which returns an array of Node objects.
Mappedin.getCollectionItemById is replaced by mapData.getById(<collection>, id)
The following classes have been redesigned. Refer to the chart below for a mapping of similar classes.
| v5 Component | v6 Component |
|---|---|
| MPIPolygon | Space |
| MPIMapGroup | FloorStack |
| MPIMap | Floor |
| MPICoordinate | Coordinate |
| MPINode | Node |
MPIState no longer exists.
UI Components
MPIFloatingLabelsManager has been replaced with Labels.
MPIFloatingLabelsManager.labelAllLocations() will be replaced with MapView.auto().
MPIMarkerManager has been replaced with Markers.
Tooltips have not been carried over from v5 and Markers should be used instead.
Updating UI Components
setPolygonColor, clearPolygonColor and other methods of changing the state of UI objects on the map is now performed using MapView.updateState(), which also supports initial for returning properties to their original state.
MPICameraManager.animate() has been renamed to Camera.animateTo().
MPIMarkerManager.animate() has been renamed to Markers.animateTo().
Interactivity
MapView.addInteractivePolygonsForAllLocations() has been replaced by updating the state of each space to be interactive as shown below.
// Set all spaces to be interactive so they can be clicked
mapView.mapData.getByType<Space>(MapDataType.SPACE) { result ->
result.onSuccess { spaces ->
spaces.forEach { space ->
mapView.updateState(space, GeometryUpdateState(interactive = true)) { }
}
}
}
Event names passed from MapView.on() have been changed:
| v5 Event | v6 Event |
|---|---|
E_SDK_EVENT.CLICK | Events.Click |
E_SDK_EVENT.MAP_CHANGED , E_SDK_EVENT.MAP_CHANGED_WITH_REASON | Events.FloorChange |
E_SDK_EVENT.OUTDOOR_VIEW_LOADED | Events.OutdoorViewLoaded |
Stacked Maps
Stacked Maps APIs have been replaced with Multi Floor View along with the ability to control the visibility and altitude of floors. Refer to the Multi Floor View and Stacked Maps guides for more information.
Map Metadata
Classes containing enterprise map metadata have been renamed.
| v5 Component | v6 Component |
|---|---|
| MPICategory | EnterpriseCategory |
| MPILocation | EnterpriseLocation |
| MPIVenue | EnterpriseVenue |
Wayfinding & Directions
MapData.getDirections() only supports getting directions between two locations. For multi destination directions, use MapData.getDirectionsMultiDestination().
MPIJourneyManager is now Navigation.
Camera
v5 MPICameraManager.tilt in radians is replaced by v6 Camera.pitch in degrees. Camera.minPitch and Camera.maxPitch are now available to set the minimum and maximum pitch values.
v5 MPICameraManager.rotation in radians is replace in v6 by Camera.bearing in degrees Clockwise rotation is now positive.
v5 Camera.zoom, Camera.minZoom and Camera.maxZoom used meters from ground level. In v6 these now use mercator zoom level units.
The following camera methods and accessors have been renamed.
Search
MPISearchManager has been changed to Search. The results returned in SearchResult are more structured:
data class SearchResult(
val enterpriseCategories: List<SearchResultEnterpriseCategory>? = null,
val enterpriseLocations: List<SearchResultEnterpriseLocations>? = null,
val places: List<SearchResultPlaces>
)
Multi Language
The methods to work with maps in multiple languages have been changed.
v6
// Specify a non default language when getting map data
val options =
GetMapDataWithCredentialsOptions(
key = "5eab30aa91b055001a68e996",
secret = "RJyRXKcryCMy4erZqqCbuB1NbR66QTGNXVE0x3Pg6oCIlUR1",
mapId = "mappedin-demo-mall",
language = "en"
)
// Get supported languages
mapData.getByType<EnterpriseVenue>(MapDataType.ENTERPRISE_VENUE) { result ->
result.onSuccess { venue ->
venue.languages.forEach { language ->
Log.d("MapData", "Language: ${language}")
}
}
}
// Change language
mapData.changeLanguage("es") { result ->
result.onSuccess {
Log.d("MapData", "Map language changed to Spanish")
}
}
Blue Dot
Blue Dot will be coming soon in v6.0.
Dynamic Focus
Dynamic Focus will be coming soon in v6.0.