Closed TouristApplication closed 1 month ago
@TouristApplication You can get current camera bound with MapboxMap.cameraBounds
Hi @evil159 thank you for the reply. We could not find a way how to access the MapBoxMap while using the viewport. We used to work with mapboxmap when we had a swift code. Now, we are only using SwiftUI codes, and seems like there is no communication between these two entities.
@TouristApplication You can use MapReader
to get access to the underlying map, as well as other properties that are found in map view.
@TouristApplication You can find an example in the SwiftUI user guide https://docs.mapbox.com/ios/maps/api/11.6.0/documentation/mapboxmaps/swiftui-user-guide#Direct-access-to-the-underlying-map-implementation
Feel free to reopen the ticket if you still have the issue
New Feature
Hello we would like to get the visible bounds of the viewport which does not seem possible with the current setting. We are using v11.6.0 and connected to the main branch. We are using the visible bounds to understand which annotations are visible on the map. Based on the visible annotations we allow users to see some items on another view. Previously we were using Swift and able to do this.
Why
It allows us to identify which annotations are visible on the visible bounds of the map. We set up an onChange function to detect when the camera center changes however the viewport always comes as nil when the camera moves. It only works when we click to another annotation. then the viewport is equal to a new center and zoom based on the annotation information and we can filter out the visible annotations on the map. Otherwise, it doesn't work.