Camera Position bounding box #458
Replies: 3 comments
-
We have lots of unimplemented stuff on Web and Desktop, but we've been trying to keep Android and iOS at feature parity. That said, I don't want to block implementing a useful feature because the ideal upstream API isn't available yet; MapLibre Native (understandably) moves much slower than MapLibre Compose. So worst case, yeah we can implement it just for Android and add some @RequiresOptIn annotation to make it clear it's not yet a multiplatform API. That said, we should look at to what extent this bounding functionality is available on iOS and Android to see if we can get something at parity at least |
Beta Was this translation helpful? Give feedback.
-
Taking a look. The native core has a few different /// We can choose to constrain the map both horizontally or vertically, only
/// vertically e.g. while panning, or screen to the specified bounds.
enum class ConstrainMode : EnumType {
None,
HeightOnly,
WidthAndHeight,
Screen,
}; and on iOS, setting - (void)setMaximumScreenBounds:(MLNCoordinateBounds)maximumScreenBounds
{
mbgl::LatLng sw = {maximumScreenBounds.sw.latitude, maximumScreenBounds.sw.longitude};
mbgl::LatLng ne = {maximumScreenBounds.ne.latitude, maximumScreenBounds.ne.longitude};
mbgl::BoundOptions newBounds = mbgl::BoundOptions().withLatLngBounds(mbgl::LatLngBounds::hull(sw, ne));
self.mbglMap.setBounds(newBounds);
self.mbglMap.setConstrainMode(mbgl::ConstrainMode::Screen);
} while the Android version doesn't seem to set a constrain mode at all void NativeMapView::setLatLngBounds(jni::JNIEnv& env, const jni::Object<mbgl::android::LatLngBounds>& jBounds) {
mbgl::BoundOptions bounds;
if (jBounds) {
bounds.withLatLngBounds(mbgl::android::LatLngBounds::getLatLngBounds(env, jBounds));
} else {
bounds.withLatLngBounds(mbgl::LatLngBounds());
}
map->setBounds(bounds);
} which I guess means the default is the center of the map ( |
Beta Was this translation helpful? Give feedback.
-
So, it's not possible to have the API behave the same on both platforms, but it is possible to implement it on both with the same signature. So I guess for now, we just implement it and document that it's different across platforms |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there
I came across this issue. In the AndroidMap and IosMap it would already be possible to constrain the camera for our desired need. This would probably work also for the JsMap, but I am not really experienced with that whole KMP Framework.
My question would be: Would you like to have a PR with said functionality but only for Android? I know it kind of defeats the purpose of KMP if certain features aren't implemented for all platforms, but still I would really like to see this feature in the library so we can port our Android app to this new Library.
Kind regards
Beta Was this translation helpful? Give feedback.
All reactions