Skip to content

Commit aa99f13

Browse files
natiginfogithub-actions[bot]
authored andcommitted
[maps-android] generate indoor manager bindings (#7714)
GitOrigin-RevId: 00a5dfd8697b92ee6521f5845e55ad191d5bbc96
1 parent 720197d commit aa99f13

File tree

7 files changed

+105
-0
lines changed

7 files changed

+105
-0
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,18 @@
498498
android:name="android.support.PARENT_ACTIVITY"
499499
android:value=".ExampleOverviewActivity" />
500500
</activity>
501+
<activity
502+
android:name=".examples.IndoorExampleActivity"
503+
android:description="@string/description_indoor"
504+
android:exported="true"
505+
android:label="@string/activity_indoor">
506+
<meta-data
507+
android:name="@string/category"
508+
android:value="@string/category_lab" />
509+
<meta-data
510+
android:name="android.support.PARENT_ACTIVITY"
511+
android:value=".ExampleOverviewActivity" />
512+
</activity>
501513
<activity
502514
android:name=".examples.TextureViewActivity"
503515
android:description="@string/description_texture_view"
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package com.mapbox.maps.testapp.examples
2+
3+
import android.os.Bundle
4+
import androidx.appcompat.app.AppCompatActivity
5+
import com.mapbox.geojson.Point
6+
import com.mapbox.maps.MapInitOptions
7+
import com.mapbox.maps.MapView
8+
import com.mapbox.maps.MapboxExperimental
9+
import com.mapbox.maps.dsl.cameraOptions
10+
import com.mapbox.maps.logD
11+
12+
/**
13+
* Example showcasing the Indoor Manager API for controlling indoor map floor display.
14+
*
15+
*/
16+
class IndoorExampleActivity : AppCompatActivity() {
17+
18+
@OptIn(MapboxExperimental::class)
19+
override fun onCreate(savedInstanceState: Bundle?) {
20+
super.onCreate(savedInstanceState)
21+
22+
// Initialize MapView with MapInitOptions and camera focused on JFK Airport
23+
// Do not commit staging or internal style URIs.
24+
val mapInitOptions = MapInitOptions(
25+
context = this,
26+
cameraOptions = cameraOptions {
27+
center(Point.fromLngLat(LONGITUDE, LATITUDE))
28+
zoom(ZOOM)
29+
bearing(BEARING)
30+
pitch(PITCH)
31+
}
32+
)
33+
34+
val mapView = MapView(this, mapInitOptions)
35+
setContentView(mapView)
36+
val mapboxMap = mapView.mapboxMap
37+
38+
mapboxMap.getStyle {
39+
// Select a specific floor (this ID should match a floor in your indoor data)
40+
// Example floor ID - replace with actual floor ID from your indoor data
41+
mapboxMap.indoor.selectFloor(FLOOR_ID)
42+
43+
// Listen to indoor state updates
44+
mapboxMap.indoor.onIndoorUpdate { indoorState ->
45+
logD(TAG, "Indoor state updated: $indoorState")
46+
logD(TAG, "Available floors: ${indoorState.floors}")
47+
logD(TAG, "Selected floor: ${indoorState.selectedFloorId}")
48+
}
49+
}
50+
}
51+
52+
companion object {
53+
private const val TAG = "IndoorExampleActivity"
54+
55+
// JFK Airport coordinates
56+
private const val LATITUDE = 40.6441
57+
private const val LONGITUDE = -73.7824
58+
private const val ZOOM = 16.0
59+
private const val BEARING = 12.0
60+
private const val PITCH = 60.0
61+
62+
// Example floor ID - should match a floor in your indoor data
63+
private const val FLOOR_ID = "b937e2aa3423453ab0552d9f"
64+
}
65+
}

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,8 @@
189189
<string name="color_theme_reset">Reset</string>
190190
<string name="color_theme_monochrome">Monochrome</string>
191191
<string name="color_theme_toggle_atmosphere">Use theme color for Atmosphere</string>
192+
193+
<!-- Indoor -->
194+
<string name="activity_indoor">Indoor Manager</string>
195+
<string name="description_indoor">Example showcasing indoor floor selection and state updates</string>
192196
</resources>

maps-sdk/api/Release/metalava.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ package com.mapbox.maps {
223223
method public com.mapbox.common.Cancelable getGeoJsonClusterLeaves(String sourceIdentifier, com.mapbox.geojson.Feature cluster, long limit = 10L, long offset = 0L, com.mapbox.maps.QueryFeatureExtensionCallback callback);
224224
method public com.mapbox.common.Cancelable getGeoJsonClusterLeaves(String sourceIdentifier, com.mapbox.geojson.Feature cluster, long limit = 10L, com.mapbox.maps.QueryFeatureExtensionCallback callback);
225225
method public com.mapbox.common.Cancelable getGeoJsonClusterLeaves(String sourceIdentifier, com.mapbox.geojson.Feature cluster, com.mapbox.maps.QueryFeatureExtensionCallback callback);
226+
method public com.mapbox.maps.IndoorManager getIndoor();
226227
method public com.mapbox.maps.MapOptions getMapOptions();
227228
method public double getMetersPerPixelAtLatitude(double latitude, double zoom);
228229
method public double getMetersPerPixelAtLatitude(double latitude);
@@ -346,6 +347,7 @@ package com.mapbox.maps {
346347
method public com.mapbox.geojson.Point unproject(com.mapbox.maps.MercatorCoordinate coordinate, double zoomScale);
347348
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) @com.mapbox.maps.MapboxExperimental public void whenSizeReady(kotlin.jvm.functions.Function0<kotlin.Unit> action);
348349
property public com.mapbox.maps.CameraState cameraState;
350+
property public final com.mapbox.maps.IndoorManager indoor;
349351
property public final com.mapbox.maps.Style? style;
350352
field public static final com.mapbox.maps.MapboxMap.Companion Companion;
351353
}

maps-sdk/api/maps-sdk.api

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public final class com/mapbox/maps/MapboxMap : com/mapbox/maps/MapboxStyleManage
224224
public final fun getGeoJsonClusterLeaves (Ljava/lang/String;Lcom/mapbox/geojson/Feature;JLcom/mapbox/maps/QueryFeatureExtensionCallback;)Lcom/mapbox/common/Cancelable;
225225
public final fun getGeoJsonClusterLeaves (Ljava/lang/String;Lcom/mapbox/geojson/Feature;Lcom/mapbox/maps/QueryFeatureExtensionCallback;)Lcom/mapbox/common/Cancelable;
226226
public static synthetic fun getGeoJsonClusterLeaves$default (Lcom/mapbox/maps/MapboxMap;Ljava/lang/String;Lcom/mapbox/geojson/Feature;JJLcom/mapbox/maps/QueryFeatureExtensionCallback;ILjava/lang/Object;)Lcom/mapbox/common/Cancelable;
227+
public final fun getIndoor ()Lcom/mapbox/maps/IndoorManager;
227228
public fun getMapOptions ()Lcom/mapbox/maps/MapOptions;
228229
public fun getMetersPerPixelAtLatitude (D)D
229230
public fun getMetersPerPixelAtLatitude (DD)D

maps-sdk/src/main/java/com/mapbox/maps/MapboxMap.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ class MapboxMap :
108108
return nativeMap.getCameraState()
109109
}
110110

111+
/**
112+
* Indoor manager for controlling indoor map floor display.
113+
*
114+
* Provides access to indoor mapping features, allowing you to select floors
115+
* and listen to indoor state updates.
116+
*
117+
* @return the [IndoorManager] instance.
118+
*/
119+
@MapboxExperimental
120+
val indoor: IndoorManager
121+
get() {
122+
checkNativeMap("indoor")
123+
return nativeMap.getIndoorManager()
124+
}
125+
111126
@get:JvmSynthetic @set:JvmSynthetic
112127
internal var cameraAnimationsPlugin: CameraAnimationsPlugin? = null
113128
@get:JvmSynthetic @set:JvmSynthetic

maps-sdk/src/main/java/com/mapbox/maps/NativeMapImpl.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,12 @@ internal class NativeMapImpl(val map: Map) {
746746
return map.viewAnnotationAvoidLayers
747747
}
748748

749+
@OptIn(com.mapbox.annotation.MapboxExperimental::class)
750+
@MapboxExperimental
751+
fun getIndoorManager(): IndoorManager {
752+
return map.indoorManager
753+
}
754+
749755
// ///// START INTERACTIONS /////////
750756

751757
fun addInteraction(interaction: Interaction): Cancelable {

0 commit comments

Comments
 (0)