Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ios/Classes/MapboxMapController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ class MapboxMapController: NSObject, FlutterPlatformView, MGLMapViewDelegate, Ma
style.localizeLabels(into: nil)
}
result(nil)
case "map#updateContentInsets":
guard let arguments = methodCall.arguments as? [String: Any] else { return }

if let bounds = arguments["bounds"] as? [String: Any],
let top = bounds["top"] as? CGFloat,
let left = bounds["left"] as? CGFloat,
let bottom = bounds["bottom"] as? CGFloat,
let right = bounds["right"] as? CGFloat,
let animated = arguments["animated"] as? Bool {
mapView.setContentInset(UIEdgeInsets(top: top, left: left, bottom: bottom, right: right), animated: animated) {
result(nil)
}
} else {
result(nil)
}
case "map#setMapLanguage":
guard let arguments = methodCall.arguments as? [String: Any] else { return }
if let localIdentifier = arguments["language"] as? String, let style = mapView.style {
Expand Down
24 changes: 24 additions & 0 deletions lib/src/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,30 @@ class MapboxMapController extends ChangeNotifier {
await _channel.invokeMethod('map#matchMapLanguageWithDeviceDefault');
}

/// Updates the distance from the edges of the map view’s frame to the edges
/// of the map view’s logical viewport, optionally animating the change.
///
/// When the value of this property is equal to `EdgeInsets.zero`, viewport
/// properties such as centerCoordinate assume a viewport that matches the map
/// view’s frame. Otherwise, those properties are inset, excluding part of the
/// frame from the viewport. For instance, if the only the top edge is inset,
/// the map center is effectively shifted downward.
///
/// The returned [Future] completes after the change has been made on the
/// platform side.
Future<void> updateContentInsets(EdgeInsets insets,
[bool animated = false]) async {
await _channel.invokeMethod('map#updateContentInsets', <String, dynamic>{
'bounds': <String, double>{
'top': insets.top,
'left': insets.left,
'bottom': insets.bottom,
'right': insets.right,
},
'animated': animated,
});
}

/// Updates the language of the map labels to match the specified language.
/// Supported language strings are available here: https://github.com/mapbox/mapbox-plugins-android/blob/e29c18d25098eb023a831796ff807e30d8207c36/plugin-localization/src/main/java/com/mapbox/mapboxsdk/plugins/localization/MapLocale.java#L39-L87
///
Expand Down