@@ -199,15 +199,30 @@ public class AppleMapController : NSObject, FlutterPlatformView, MKMapViewDelega
199
199
case " camera#animate " :
200
200
let positionData : Dictionary < String , Any > = self . toPositionData ( data: args [ " cameraUpdate " ] as! Array < Any > , animated: true )
201
201
if !positionData. isEmpty {
202
- self . mapView. setCenterCoordinate ( positionData, animated: true )
202
+ guard let _ = positionData [ " moveToBounds " ] else {
203
+ self . mapView. setCenterCoordinate ( positionData, animated: true )
204
+ return
205
+ }
206
+ self . mapView. setBounds ( positionData, animated: true )
203
207
}
204
208
result ( nil )
205
209
case " camera#move " :
206
210
let positionData : Dictionary < String , Any > = self . toPositionData ( data: args [ " cameraUpdate " ] as! Array < Any > , animated: false )
207
211
if !positionData. isEmpty {
208
- self . mapView. setCenterCoordinate ( positionData, animated: false )
212
+ guard let _ = positionData [ " moveToBounds " ] else {
213
+ self . mapView. setCenterCoordinate ( positionData, animated: false )
214
+ return
215
+ }
216
+ self . mapView. setBounds ( positionData, animated: false )
209
217
}
210
218
result ( nil )
219
+ case " camera#convert " :
220
+ guard let annotation = args [ " annotation " ] as? Array < Double > else {
221
+ result ( nil )
222
+ return
223
+ }
224
+ let point = self . mapView. convert ( CLLocationCoordinate2D ( latitude: annotation [ 0 ] , longitude: annotation [ 1 ] ) , toPointTo: self . view ( ) )
225
+ result ( [ " point " : [ point. x, point. y] ] )
211
226
default :
212
227
result ( FlutterMethodNotImplemented)
213
228
return
@@ -261,6 +276,11 @@ public class AppleMapController : NSObject, FlutterPlatformView, MKMapViewDelega
261
276
let zoom : Double = data [ 2 ] as? Double ?? 0
262
277
positionData = [ " target " : _positionData, " zoom " : zoom]
263
278
}
279
+ case " newLatLngBounds " :
280
+ if let _positionData: Array < Any > = data [ 1 ] as? Array < Any > {
281
+ let padding : Double = data [ 2 ] as? Double ?? 0
282
+ positionData = [ " target " : _positionData, " padding " : padding, " moveToBounds " : true ]
283
+ }
264
284
case " zoomBy " :
265
285
if let zoomBy: Double = data [ 1 ] as? Double {
266
286
mapView. zoomBy ( zoomBy: zoomBy, animated: animated)
0 commit comments