mapbox-maps-flutter
mapbox-maps-flutter copied to clipboard
It is not possible to fit the map to a bounds using the cameraForCoordinates... methods on iOS
On Android it is possible to move the camera to fit a bounds. On iOS the same code fails to work.
Swap the varialbe c[n] at the end of this code to test the different methods. All are fine on Android but fail on an iPhone:
var sw = Point(coordinates: Position(bounds.w, bounds.s));
var ne = Point(coordinates: Position(bounds.e, bounds.n));
CameraOptions c = await mapboxMap.cameraForCoordinateBounds(
CoordinateBounds(southwest: sw, northeast: ne, infiniteBounds: false),
MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight),
0,
MapConst.defaultFindZoomLevel,
20,
ScreenCoordinate(x: 0, y: 0),
);
CameraOptions c2 = await mapboxMap.cameraForCoordinatesPadding(
[sw, ne],
CameraOptions(pitch: 40),
MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight),
MapConst.defaultFindZoomLevel,
ScreenCoordinate(x: 0, y: 0),
);
CameraOptions c3 = await mapboxMap.cameraForCoordinates([sw, ne], MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight), 0, 0);
CameraOptions c4 = await mapboxMap.cameraForCoordinatesCameraOptions([sw, ne], CameraOptions(), ScreenBox(min: ScreenCoordinate(x: 0, y: 0), max: ScreenCoordinate(x: 100, y: 100)));
var point = {
"type": "Point",
"coordinates": [1, 2]
};
CameraOptions c5 = await mapboxMap.cameraForGeometry(point, MbxEdgeInsets(top: paddingTop, left: paddingLeft, bottom: paddingBottom, right: paddingRight), 0, 0);
mapboxMap.easeTo(c, MapAnimationOptions());
`