mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

Use of local assets on Android while loading Models

Open M4dhav opened this issue 9 months ago • 1 comments

On the Android platform, when loading models using final carModelUri = "asset://assets/sportcar.glb"; the car model is not loaded. Upon compiling an APK of the example app and using the Android Studio APK Analyzer, I discovered that Flutter was bundling the assets under flutter_assets/assets/ instead of the assets/ folder. I then replaced the path in my code as
final carModelUri = "asset://flutter_assets/assets/sportcar.glb"; and the car did indeed load. I believe this either needs to be mentioned in the Example for loading 3D Models or the library should intrinsically handle adding flutter_assets to path when loading assets on Android

M4dhav avatar Mar 19 '25 09:03 M4dhav

Hi @M4dhav, may I ask which MapboxMaps Flutter version are you using? We are aware of the bundled assets and including the correct asset path when creating a Model from v2.2.0 https://github.com/mapbox/mapbox-maps-flutter/blob/5606859e7ce8ed0d08a9ffbc8e642b7c810c0917/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxOptionsController.kt#L46-L48 However, this will not work with addStyleModel API if that's what you are using, instead you can set modelId when creating a model as shown here https://github.com/mapbox/mapbox-maps-flutter/issues/736#issuecomment-2419678685

maios avatar Mar 19 '25 09:03 maios