@@ -182,10 +182,13 @@ MLNMapViewDelegate {
182
182
183
183
// Cancel any existing camera update completion task.
184
184
cameraUpdateTask? . cancel ( )
185
- cameraUpdateContinuation = nil
186
185
187
186
cameraUpdateTask = Task { @MainActor in
188
187
return await withCheckedContinuation { continuation in
188
+ // Clean up the continuation if it was already set.
189
+ cameraUpdateContinuation? . resume ( )
190
+ cameraUpdateContinuation = nil
191
+
189
192
// Store the continuation to be resumed in mapViewDidBecomeIdle
190
193
cameraUpdateContinuation = continuation
191
194
@@ -234,35 +237,27 @@ MLNMapViewDelegate {
234
237
235
238
mapView. userTrackingMode = . follow
236
239
237
- mapView. setZoomLevel ( zoom , animated : false )
240
+ mapView. zoomLevel = zoom
238
241
mapView. direction = direction
239
242
240
243
mapView. minimumPitch = pitch
241
244
mapView. maximumPitch = pitch
242
245
mapView. minimumPitch = pitchRange. rangeValue. lowerBound
243
246
mapView. maximumPitch = pitchRange. rangeValue. upperBound
244
-
245
247
} else {
246
248
mapView. setUserTrackingMode ( . follow, animated: animated) {
247
249
guard mapView. userTrackingMode == . follow else {
248
250
// Exit early if the user tracking mode is no longer set to follow
249
251
return
250
252
}
251
253
254
+ mapView. zoomLevel = zoom
255
+ mapView. direction = direction
256
+
257
+ mapView. minimumPitch = pitch
258
+ mapView. maximumPitch = pitch
252
259
mapView. minimumPitch = pitchRange. rangeValue. lowerBound
253
260
mapView. maximumPitch = pitchRange. rangeValue. upperBound
254
- let camera = mapView. camera
255
- camera. heading = direction
256
- camera. pitch = pitch
257
-
258
- let altitude = MLNAltitudeForZoomLevel (
259
- zoom,
260
- pitch,
261
- mapView. camera. centerCoordinate. latitude,
262
- mapView. frame. size
263
- )
264
- camera. altitude = altitude
265
- mapView. setCamera ( camera, animated: animated)
266
261
}
267
262
}
268
263
case let . trackingUserLocationWithHeading( zoom: zoom, pitch: pitch, pitchRange: pitchRange) :
@@ -272,32 +267,26 @@ MLNMapViewDelegate {
272
267
// Needs to be non-animated or else it messes up following
273
268
274
269
mapView. userTrackingMode = . followWithHeading
275
- mapView. setZoomLevel ( zoom, animated: false )
270
+
271
+ mapView. zoomLevel = zoom
272
+
276
273
mapView. minimumPitch = pitch
277
274
mapView. maximumPitch = pitch
278
275
mapView. minimumPitch = pitchRange. rangeValue. lowerBound
279
276
mapView. maximumPitch = pitchRange. rangeValue. upperBound
280
-
281
277
} else {
282
278
mapView. setUserTrackingMode ( . followWithHeading, animated: animated) {
283
279
guard mapView. userTrackingMode == . followWithHeading else {
284
280
// Exit early if the user tracking mode is no longer set to followWithHeading
285
281
return
286
282
}
287
283
284
+ mapView. zoomLevel = zoom
285
+
286
+ mapView. minimumPitch = pitch
287
+ mapView. maximumPitch = pitch
288
288
mapView. minimumPitch = pitchRange. rangeValue. lowerBound
289
289
mapView. maximumPitch = pitchRange. rangeValue. upperBound
290
- let camera = mapView. camera
291
-
292
- let altitude = MLNAltitudeForZoomLevel (
293
- zoom,
294
- pitch,
295
- mapView. camera. centerCoordinate. latitude,
296
- mapView. frame. size
297
- )
298
- camera. altitude = altitude
299
- camera. pitch = pitch
300
- mapView. setCamera ( camera, animated: animated)
301
290
}
302
291
}
303
292
case let . trackingUserLocationWithCourse( zoom: zoom, pitch: pitch, pitchRange: pitchRange) :
@@ -307,36 +296,32 @@ MLNMapViewDelegate {
307
296
// so let's do something else instead.
308
297
// Needs to be non-animated or else it messes up following
309
298
310
- mapView. setZoomLevel ( zoom, animated: false )
299
+ mapView. zoomLevel = zoom
300
+
311
301
mapView. minimumPitch = pitch
312
302
mapView. maximumPitch = pitch
313
303
mapView. minimumPitch = pitchRange. rangeValue. lowerBound
314
304
mapView. maximumPitch = pitchRange. rangeValue. upperBound
315
-
316
305
} else {
317
306
mapView. setUserTrackingMode ( . followWithCourse, animated: animated) {
318
307
guard mapView. userTrackingMode == . followWithCourse else {
319
308
// Exit early if the user tracking mode is no longer set to followWithCourse
320
309
return
321
310
}
322
311
312
+ mapView. zoomLevel = zoom
313
+
314
+ mapView. minimumPitch = pitch
315
+ mapView. maximumPitch = pitch
323
316
mapView. minimumPitch = pitchRange. rangeValue. lowerBound
324
317
mapView. maximumPitch = pitchRange. rangeValue. upperBound
325
-
326
- let camera = mapView. camera
327
-
328
- let altitude = MLNAltitudeForZoomLevel (
329
- zoom,
330
- pitch,
331
- mapView. camera. centerCoordinate. latitude,
332
- mapView. frame. size
333
- )
334
- camera. altitude = altitude
335
- camera. pitch = pitch
336
- mapView. setCamera ( camera, animated: animated)
337
318
}
338
319
}
339
320
case let . rect( boundingBox, padding) :
321
+ mapView. minimumPitch = 0
322
+ mapView. maximumPitch = 0
323
+ mapView. direction = 0
324
+
340
325
mapView. setVisibleCoordinateBounds ( boundingBox,
341
326
edgePadding: padding,
342
327
animated: animated,
0 commit comments