@@ -199,15 +199,30 @@ public class AppleMapController : NSObject, FlutterPlatformView, MKMapViewDelega
199199 case " camera#animate " :
200200 let positionData : Dictionary < String , Any > = self . toPositionData ( data: args [ " cameraUpdate " ] as! Array < Any > , animated: true )
201201 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 )
203207 }
204208 result ( nil )
205209 case " camera#move " :
206210 let positionData : Dictionary < String , Any > = self . toPositionData ( data: args [ " cameraUpdate " ] as! Array < Any > , animated: false )
207211 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 )
209217 }
210218 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] ] )
211226 default :
212227 result ( FlutterMethodNotImplemented)
213228 return
@@ -261,6 +276,11 @@ public class AppleMapController : NSObject, FlutterPlatformView, MKMapViewDelega
261276 let zoom : Double = data [ 2 ] as? Double ?? 0
262277 positionData = [ " target " : _positionData, " zoom " : zoom]
263278 }
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+ }
264284 case " zoomBy " :
265285 if let zoomBy: Double = data [ 1 ] as? Double {
266286 mapView. zoomBy ( zoomBy: zoomBy, animated: animated)
0 commit comments