Closed Adraesh closed 5 months ago
@Adraesh Hi, thank you for the report, we work on it.
Did you try to use the standard SwiftUI support from the sdk https://docs.mapbox.com/ios/maps/api/11.2.0/documentation/mapboxmaps/map? Would that help with the issue?
@persidskiy
Thank you for your prompte answer.
I am not quite sure how to implement the standard SwiftUI along with the architecture which we have already in place since more than 4 years now (before any mapbox swift ui support).
As you saw in my previous code, we have a singleton that holds a reference to the MapView in this way we can interact with the map wherever and whenever we want without being locked by a context.
Using this same approach how would you use the "standard SwiftUI support" and instanciate a Map and retaining a global reference of it?
Is there a way to instanciate a Map() with a MapView object or any related object?
I am missing something here.
@Adraesh
As you saw in my previous code, we have a singleton that holds a reference to the MapView in this way we can interact with the map wherever and whenever we want without being locked by a context.
Using this same approach how would you use the "standard SwiftUI support" and instanciate a Map and retaining a global reference of it?
The Map
implementation doesn't allow you to use the singleton MapView
, as this would break any guarantees on the Map
API and generally is unwanted practice.
Is there a way to instanciate a Map() with a MapView object or any related object?
No, if you use Map
view in SwiftUI, it wraps most of MapView
functionality in declarative way. However, in some rare cases you can access the underlying MapboxMap
and other objects available in MapProxy
via MapReader
https://docs.mapbox.com/ios/maps/api/11.2.0/documentation/mapboxmaps/swiftui-user-guide#Direct-access-to-the-underlying-map-implementation
@persidskiy Thank you very much.
Will check the 11.3.0-beta.1
It works perfectly. Thank you @persidskiy
@persidskiy I'm also seeing this even though I'm not setting the map's size anywhere in my code nor am I using UIKit. Would you mind explain what this error means? Should I just ignore it since it's now a warning?
Environment
Observed behavior and steps to reproduce
[Error]: Invalid size is used for setting the map view, fall back to the default size{64, 64}. MapboxMaps/MapView.swift:589: Assertion failed
Expected behavior
No crash should happen, just like on v11.1.0 of Mapbox SDK.
Our integration (works fine on 11.1.0: