• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Maps Delegate implementation

This example lists all of the NGLMapViewDelegate methods and describes each of them.

For all code examples, refer to Maps Code Examples

MapViewDelegateViewController view source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
import Foundation
import UIKit
import Nbmap
class MapViewDelegateViewController: UIViewController {
    var nbMapView: NGLMapView! {
        didSet {
            oldValue?.removeFromSuperview()
            if let mapView = nbMapView {
                configureMapView(nbMapView)
                view.insertSubview(mapView, at: 0)
            }
        }
    }
    
    func configureMapView(_ mapView: NGLMapView) {
        mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        //Set the delegate
        mapView.delegate = self
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        nbMapView = NGLMapView(frame:self.view.bounds)
    }
    
    
}
extension MapViewDelegateViewController: NGLMapViewDelegate {
    /**
     Tells the user that the map has just finished loading a style.
     This method is called during the initialization of the map view and after any
     subsequent loading of a new style. This method is called between the
     `-mapViewWillStartRenderingMap:` and `-mapViewDidFinishRenderingMap:` delegate
     methods. Changes to sources or layers of the current style do not cause this
     method to be called.
     This method is the earliest opportunity to modify the layout or appearance of
     the current style before the map view is displayed to the user.
     @param mapView The map view that has just loaded a style.
     @param style The style that was loaded.
     */
    func mapView(_ mapView: NGLMapView, didFinishLoading style: NGLStyle){
        let camera = NGLMapCamera(lookingAtCenter: CLLocationCoordinate2DMake(53.5511, 9.9937),
                                                                      acrossDistance:1000,
                                                                               pitch:0,
                                                                             heading:0)
        nbMapView.fly(to: camera)
    
    }
    
    /**
     Asks the user whether the map view should be allowed to change from the
     existing camera to the new camera in response to a user gesture.
     This method is called as soon as the user gesture is recognized. It is not
     called in response to a programmatic camera change, such as by setting the
     `centerCoordinate` property or calling `-flyToCamera:completionHandler:`.
     This method is called many times during gesturing, so you should avoid performing
     complex or performance-intensive tasks in your implementation.
     @param mapView The map view that the user is manipulating.
     @param oldCamera The camera representing the viewpoint at the moment the
     gesture is recognized. If this method returns `NO`, the map view's camera
     continues to be this camera.
     @param newCamera The expected camera after the gesture completes. If this
     method returns `YES`, this camera becomes the map view's camera.
     @return A Boolean value indicating whether the map view should stay at
     `oldCamera` or change to `newCamera`.
     */
    private func mapView(_ mapView: NGLMapView, shouldChangeFromCamera oldCamera: NGLMapCamera, to newCamera: NGLMapCamera ){
       
    
    }
    
    /**
     Asks the user whether the map view should be allowed to change from the
     existing camera to the new camera in response to a user gesture.
     This method is called as soon as the user gesture is recognized. It is not
     called in response to a programmatic camera change, such as by setting the
     `centerCoordinate` property or calling `-flyToCamera:completionHandler:`.
     This method is called many times during gesturing, so you should avoid performing
     complex or performance-intensive tasks in your implementation.
     @param mapView The map view that the user is manipulating.
     @param oldCamera The camera representing the viewpoint at the moment the
     gesture is recognized. If this method returns `NO`, the map view's camera
     continues to be this camera.
     @param newCamera The expected camera after the gesture completes. If this
     method returns `YES`, the viewport of the map will transition to the new camera. Note that the new camera cannot be modified.
     @param reason The reason for the camera change.
     @return A Boolean value indicating whether the map view should stay at
     `oldCamera` or transition to `newCamera`.
     @note If this method is implemented `-mapView:shouldChangeFromCamera:toCamera:` will not be called.
     */
    func mapView(_ mapView: NGLMapView, shouldChangeFrom oldCamera: NGLMapCamera, to  newCamera: NGLMapCamera, reason: NGLCameraChangeReason) -> Bool {
       return true
    }
    
    /**
     Tells the user that the viewpoint depicted by the map view is about to change.
     This method is called whenever the currently displayed map camera will start
     changing for any reason.
     @param mapView The map view whose viewpoint will change.
     @param animated Whether the change will cause an animated effect on the map.
     */
    func mapView(_ mapView: NGLMapView, regionWillChangeAnimated animated: Bool){
       
    
    }
   
    /**
     Tells the user that the viewpoint depicted by the map view is about to change.
     This method is called whenever the currently displayed map camera will start
     changing for any reason.
     @param mapView The map view whose viewpoint will change.
     @param animated Whether the change will cause an animated effect on the map.
     @param reason The reason for the camera change.
     @note If this method is implemented `-mapView:regionWillChangeAnimated:` will not be called.
     */
    func mapView(_ mapView: NGLMapView, regionWillChangeWith reason: NGLCameraChangeReason, animated: Bool){
       
    
    }
    
    /**
     Tells the user that the viewpoint depicted by the map view is changing.
     This method is called as the currently displayed map camera changes as part of
     an animation, whether due to a user gesture or due to a call to a method such
     as `-[NGLMapView setCamera:animated:]`. This method can be called before
     `-mapViewDidFinishLoadingMap:` is called.
     During the animation, this method may be called many times to report updates to
     the viewpoint. Therefore, your implementation of this method should be as lightweight
     as possible to avoid affecting performance.
     @param mapView The map view whose viewpoint is changing.
     */
    func mapViewRegionIsChanging(_ mapView: NGLMapView){
       
    
    }
   
    /**
     Tells the user that the viewpoint depicted by the map view is changing.
     This method is called as the currently displayed map camera changes as part of
     an animation, whether due to a user gesture or due to a call to a method such
     as `-[NGLMapView setCamera:animated:]`. This method can be called before
     `-mapViewDidFinishLoadingMap:` is called.
     During the animation, this method may be called many times to report updates to
     the viewpoint. Therefore, your implementation of this method should be as lightweight
     as possible to avoid affecting performance.
     @param mapView The map view whose viewpoint is changing.
     @param reason The reason for the camera change.
     @note If this method is implemented `-mapViewRegionIsChanging:` will not be called.
     */
    func mapView(_ mapView: NGLMapView, regionIsChangingWith reason: NGLCameraChangeReason){
       
    
    }
  
    /**
     Tells the user that the viewpoint depicted by the map view has finished
     changing.
     This method is called whenever the currently displayed map camera has finished
     changing, after any calls to `-mapViewRegionIsChanging:` due to animation. Therefore,
     this method can be called before `-mapViewDidFinishLoadingMap:` is called.
     @param mapView The map view whose viewpoint has changed.
     @param animated Whether the change caused an animated effect on the map.
     */
    func mapView(_ mapView: NGLMapView, regionDidChangeAnimated animated: Bool){
       
    
    }
    
    /**
     Tells the user that the viewpoint depicted by the map view has finished
     changing.
     This method is called whenever the currently displayed map camera has finished
     changing, after any calls to `-mapViewRegionIsChanging:` due to animation. Therefore,
     this method can be called before `-mapViewDidFinishLoadingMap:` is called.
     @param mapView The map view whose viewpoint has changed.
     @param animated Whether the change caused an animated effect on the map.
     @param reason The reason for the camera change.
     @note If this method is implemented `-mapView:regionDidChangeAnimated:` will not be called.
     */
    func mapView(_ mapView: NGLMapView, regionDidChangeWith reason: NGLCameraChangeReason, animated: Bool){
       
    
    }
  
//    ##pragma mark Loading the Map
    
    /**
     Tells the user that the map view will begin to load.
     This method is called whenever the map view starts loading, including when a
     new style has been set and the map must reload.
     @param mapView The map view that is starting to load.
     */
    func mapViewWillStartLoadingMap(_ mapView: NGLMapView) {
        
    }
    
    /**
     Tells the user that the map view has finished loading.
     This method is called whenever the map view finishes loading, either after the
     initial load or after a style change has forced a reload.
     @param mapView The map view that has finished loading.
     */
    func mapViewDidFinishLoadingMap(_ mapView: NGLMapView) {
        
    }
    
    /**
     Tells the user that the map view was unable to load data needed for
     displaying the map.
     This method may be called for a variety of reasons, including a network
     connection failure or a failure to fetch the style from the server. You can use
     the given error message to notify the user that map data is unavailable.
     @param mapView The map view that is unable to load the data.
     @param error The reason the data could not be loaded.
     */
    func mapViewDidFailLoadingMap(_ apView: NGLMapView,withError error: Error) {
        
    }
    
    /**
     Tells the user that the map view is about to redraw.
     This method is called any time the map view needs to redraw due to a change in
     the viewpoint or style property transition. This method may be called very
     frequently, even moreso than `-mapViewRegionIsChanging:`. Therefore, your
     implementation of this method should be as lightweight as possible to avoid
     affecting performance.
     @param mapView The map view that is about to redraw.
     */
    func mapViewWillStartRenderingFrame(_ mapView: NGLMapView ) {
        
    }
    
    /**
     Tells the user that the map view has just redrawn.
     This method is called any time the map view needs to redraw due to a change in
     the viewpoint or style property transition. This method may be called very
     frequently, even moreso than `-mapViewRegionIsChanging:`. Therefore, your
     implementation of this method should be as lightweight as possible to avoid
     affecting performance.
     @param mapView The map view that has just redrawn.
     */
    func mapViewDidFinishRenderingFrame(_ mapView: NGLMapView,fullyRendered:Bool) {
        
    }
    
    /**
     Tells the user that the map view is entering an idle state, and no more
     drawing will be necessary until new data is loaded or there is some interaction
     with the map.
     
     - No camera transitions are in progress
     - All currently requested tiles have loaded
     - All fade/transition animations have completed
     
     @param mapView The map view that has just entered the idle state.
     */
    func mapViewDidBecomeIdle(_ mapView: NGLMapView ) {
        
    }
    
    func mapView(_ mapView: NGLMapView, didFailToLoadImage imageName: String) -> UIImage? {
        return nil
    }
  
    /**
     Asks the user whether the map view should evict cached images.
     
     This method is called in two scenarios: when the cumulative size of unused images
     exceeds the cache size or when the last tile that includes the image is removed from
     memory.
     
     @param mapView The map view that is evicting the image.
     @param imageName The image name that is going to be removed.
     @return A Boolean value indicating whether the map view should evict
     the cached image.
     */
    func mapView(_ mapView: NGLMapView, shouldRemoveStyleImage imageName: String) -> Bool {
        return true
    }
   
//    #pragma mark Tracking User Location
    
    /**
     Tells the user that the map view will begin tracking the user's location.
     This method is called when the value of the `showsUserLocation` property
     changes to `YES`.
     @param mapView The map view that is tracking the user's location.
     */
    func mapViewWillStartLocatingUser(_ mapView: NGLMapView) {
       
    }
    
    /**
     Tells the user that the map view has stopped tracking the user's location.
     This method is called when the value of the `showsUserLocation` property
     changes to `NO`.
     @param mapView The map view that is tracking the user's location.
     */
    func mapViewDidStopLocatingUser(_ mapView: NGLMapView) {
       
    }
    
    
    /**
     Asks the user styling options for each default user location annotation view.
     
     This method is called many times during gesturing, so you should avoid performing
     complex or performance-intensive tasks in your implementation.
     
     @param mapView The map view that is tracking the user's location.
     */
    func mapView(styleForDefaultUserLocationAnnotationView mapView: NGLMapView) -> NGLUserLocationAnnotationViewStyle {
        let locationStyle =  NGLUserLocationAnnotationViewStyle()
        /**
         The fill color for the puck view.
         */
        locationStyle.puckFillColor = UIColor.blue
        /**
         The shadow color for the puck view.
         */
        locationStyle.puckShadowColor = UIColor.red
        /**
         The shadow opacity for the puck view.
         Set any value between 0.0 and 1.0.
         The default value of this property is equal to `0.25`
         */
        locationStyle.puckShadowOpacity = 0.25
        /**
         The fill color for the arrow puck.
         */
        locationStyle.puckArrowFillColor = UIColor.black
        /**
         The fill color for the puck view.
         */
        locationStyle.haloFillColor = UIColor.white
       
        if #available(iOS 14, *) {
            /**
             The halo fill color for the approximate view.
             */
            locationStyle.approximateHaloFillColor = UIColor.white
            /**
             The halo border color for the approximate view.
             */
            locationStyle.approximateHaloBorderColor = UIColor.white
            /**
             The halo border width for the approximate view.
             The default value of this property is equal to `2.0`
             */
            locationStyle.approximateHaloBorderWidth = 2.0
            /**
             The halo opacity for the approximate view.
             Set any value between 0.0 and 1.0
             The default value of this property is equal to `0.15`
             */
            locationStyle.approximateHaloOpacity = 0.15
        }
      
        return locationStyle
    }
    
    /**
     Tells the user that the location of the user was updated.
     While the `showsUserLocation` property is set to `YES`, this method is called
     whenever a new location update is received by the map view. This method is also
     called if the map view's user tracking mode is set to
     `NGLUserTrackingModeFollowWithHeading` and the heading changes, or if it is set
     to `NGLUserTrackingModeFollowWithCourse` and the course changes.
     This method is not called if the application is currently running in the
     background. If you want to receive location updates while running in the
     background, you must use the Core Location framework.
     private  @param mapView The map view that is tracking the user's location.
     @param userLocation The location object representing the user's latest
        location. This property may be `nil`.
     */
    func mapView(_ mapView: NGLMapView, didUpdate userLocation: NGLUserLocation?) {
        
    }
  
    /**
     Tells the user that an attempt to locate the user's position failed.
     @param mapView The map view that is tracking the user's location.
     @param error An error object containing the reason why location tracking
        failed.
     */
    func mapView(_ mapView: NGLMapView, didFailToLocateUserWithError error: Error)  {
        
    }
    
    
    /**
     Tells the user that the map view's user tracking mode has changed.
     This method is called after the map view asynchronously changes to reflect the
     new user tracking mode, for example by beginning to zoom or rotate.
     private  @param mapView The map view that changed its tracking mode.
     @param mode The new tracking mode.
     @param animated Whether the change caused an animated effect on the map.
     */
    func mapView(_ mapView: NGLMapView, didChange mode: NGLUserTrackingMode, animated: Bool )  {
        
    }
  
    /**
     Returns a screen coordinate at which to position the user location annotation.
     This coordinate is relative to the map view's origin after applying the map view's
     content insets.
     When unimplemented, the user location annotation is aligned within the center of
     the map view with respect to the content insets.
     This method will override any values set by `NGLMapView.userLocationVerticalAlignment`
     or `-[NGLMapView setUserLocationVerticalAlignment:animated:]`.
     @param mapView The map view that is tracking the user's location.
     
     We don't need to set the anchor point for now, so comment out this method first
     */
//    func mapViewUserLocationAnchorPoint(_ mapView: NGLMapView ) -> CGPoint {
//        return nil
//    }
    /**
     Tells the user that the map's location updates accuracy authorization has changed.
     
     This method is called after the user changes location accuracy authorization when
     requesting location permissions or in privacy settings.
     
     @param mapView The map view that changed its location accuracy authorization.
     @param manager The location manager reporting the update.
     
     */
    func mapView(_ apView: NGLMapView, didChangeLocationManagerAuthorization manager: NGLLocationManager)  {
        
    }
  
                                                                                                                       
//    #pragma mark Managing the Appearance of Annotations
    /**
     Returns an annotation image object to mark the given point annotation object on
     the map.
     Implement this method to mark a point annotation with a static image. If you
     want to mark a particular point annotation with an annotation view instead,
     omit this method or have it return `nil` for that annotation, then implement
     `-mapView:viewForAnnotation:`.
     Static annotation images use less memory and draw more quickly than annotation
     views. On the other hand, annotation views are compatible with UIKit, Core
     Animation, and other Cocoa Touch frameworks.
     @param mapView The map view that requested the annotation image.
     @param annotation The object representing the annotation that is about to be
        displayed.
     @return The annotation image object to display for the given annotation or
        `nil` if you want to display the default marker image or an annotation view.
     */
    func mapView(_ mapView: NGLMapView, imageFor annotation: NGLAnnotation) -> NGLAnnotationImage?  {
        return nil
    }
    /**
     Returns the alpha value to use when rendering a shape annotation.
     A value of `0.0` results in a completely transparent shape. A value of `1.0`,
     the default, results in a completely opaque shape.
     This method sets the opacity of an entire shape, inclusive of its stroke and
     fill. To independently set the values for stroke or fill, specify an alpha
     component in the color returned by `-mapView:strokeColorForShapeAnnotation:` or
     `-mapView:fillColorForPolygonAnnotation:`.
     @param mapView The map view rendering the shape annotation.
     @param annotation The annotation being rendered.
     @return An alpha value between `0` and `1.0`.
     */
    func mapView(_ mapView: NGLMapView, alphaForShapeAnnotation annotation: NGLShape) -> CGFloat  {
        return 1.0
    }
    /**
     Returns the color to use when rendering the outline of a shape annotation.
     The default stroke color is the map view's tint color. If a pattern color is
     specified, the result is undefined.
     Opacity may be set by specifying an alpha component. The default alpha value is
     `1.0` and results in a completely opaque stroke.
     @param mapView The map view rendering the shape annotation.
     @param annotation The annotation being rendered.
     @return A color to use for the shape outline.
     */
    func mapView(_ mapView: NGLMapView, strokeColorForShapeAnnotation annotation: NGLShape) -> UIColor  {
        return UIColor.red
    }
    /**
     Returns the color to use when rendering the fill of a polygon annotation.
     The default fill color is the map view's tint color. If a pattern color is
     specified, the result is undefined.
     Opacity may be set by specifying an alpha component. The default alpha value is
     `1.0` and results in a completely opaque shape.
     @param mapView The map view rendering the polygon annotation.
     @param annotation The annotation being rendered.
     @return The polygon's interior fill color.
     */
    
    func mapView(_ mapView: NGLMapView, fillColorForPolygonAnnotation annotation: NGLPolygon) -> UIColor  {
        return UIColor.red
    }
   
    /**
     Returns the line width in points to use when rendering the outline of a
     polyline annotation.
     By default, the polyline is outlined with a line `3.0` points wide.
     @param mapView The map view rendering the polygon annotation.
     @param annotation The annotation being rendered.
     @return A line width for the polyline, measured in points.
     */
    func mapView(_ mapView: NGLMapView, lineWidthForPolylineAnnotation annotation: NGLPolyline) -> CGFloat  {
        return 3.0
    }
//    #pragma mark Managing Annotation Views
    /**
     Returns a view object to mark the given point annotation object on the map.
     Implement this method to mark a point annotation with a view object. If you
     want to mark a particular point annotation with a static image instead, omit
     this method or have it return `nil` for that annotation, then implement
     `-mapView:imageForAnnotation:` instead.
     Annotation views are compatible with UIKit, Core Animation, and other Cocoa
     Touch frameworks. On the other hand, static annotation images use less memory
     and draw more quickly than annotation views.
     The user location annotation view can also be customized via this method. When
     `annotation` is an instance of `NGLUserLocation` (or equal to the map view's
     `userLocation` property), return an instance of `NGLUserLocationAnnotationView`
     (or a subclass thereof).
     @param mapView The map view that requested the annotation view.
     @param annotation The object representing the annotation that is about to be
        displayed.
     @return The view object to display for the given annotation or `nil` if you
        want to display an annotation image instead.
     */
    func mapView(_ mapView: NGLMapView, viewFor annotation: NGLAnnotation) -> NGLAnnotationView?  {
        return nil
    }
    
    /**
     Tells the user that one or more annotation views have been added and
     positioned on the map.
     This method is called just after the views are added to the map. You can
     implement this method to animate the addition of the annotation views.
     @param mapView The map view to which the annotation views were added.
     @param annotationViews An array of `NGLAnnotationView` objects representing the
        views that were added.
     */
    func mapView(mapView: NGLMapView, didAddAnnotationViews annotationViews: [NGLAnnotation]) {
        
    }
    
//    #pragma mark Selecting Annotations
    /**
     Returns a Boolean value indicating whether the shape annotation can be selected.
     If the return value is `YES`, the user can select the annotation by tapping
     on it. If the delegate does not implement this method, the default value is `YES`.
     @param mapView The map view that has selected the annotation.
     @param annotation The object representing the shape annotation.
     @return A Boolean value indicating whether the annotation can be selected.
     */
    func mapView(_ mapView: NGLMapView, shapeAnnotationIsEnabled annotation: NGLShape) -> Bool{
        return true
    }
    
    /**
     Tells the user that one of its annotations was selected.
     You can use this method to track changes in the selection state of annotations.
     If the annotation is associated with an annotation view, you can also implement
     `-mapView:didSelectAnnotationView:`, which is called immediately after this
     method is called.
     @param mapView The map view containing the annotation.
     @param annotation The annotation that was selected.
     */
    func mapView(_ mapView: NGLMapView, didSelect annotation: NGLAnnotation){
        
    }
    /**
     Tells the user that one of its annotations was deselected.
     You can use this method to track changes in the selection state of annotations.
     If the annotation is associated with an annotation view, you can also implement
     `-mapView:didDeselectAnnotationView:`, which is called immediately after this
     method is called.
     @param mapView The map view containing the annotation.
     @param annotation The annotation that was deselected.
     */
    func mapView(_ mapView: NGLMapView, didDeselect annotation: NGLAnnotation){
        
    }
    
    /**
     Tells the user that one of its annotation views was selected.
     You can use this method to track changes in the selection state of annotation
     views.
     This method is only called for annotation views. To track changes in the
     selection state of all annotations, including those associated with static
     annotation images, implement `-mapView:didSelectAnnotation:`, which is called
     immediately before this method is called.
     @param mapView The map view containing the annotation.
     @param annotationView The annotation view that was selected.
     */
    func mapView(_ mapView: NGLMapView, didSelect annotationView: NGLAnnotationView){
        
    }
    
    /**
     Tells the user that one of its annotation views was deselected.
     You can use this method to track changes in the selection state of annotation
     views.
     This method is only called for annotation views. To track changes in the
     selection state of all annotations, including those associated with static
     annotation images, implement `-mapView:didDeselectAnnotation:`, which is called
     immediately before this method is called.
     @param mapView The map view containing the annotation.
     @param annotationView The annotation view that was deselected.
     */
    func mapView(_ mapView: NGLMapView, didDeselect annotationView: NGLAnnotationView){
        
    }
//    #pragma mark Managing Callout Views
    /**
     Returns a Boolean value indicating whether the annotation is able to display
     extra information in a callout bubble.
     This method is called after an annotation is selected, before any callout is
     displayed for the annotation.
     If the return value is `YES`, a callout view is shown when the user taps on an
     annotation, selecting it. The default callout displays the annotation's title
     and subtitle. You can add accessory views to either end of the callout by
     implementing the `-mapView:leftCalloutAccessoryViewForAnnotation:` and
     `-mapView:rightCalloutAccessoryViewForAnnotation:` methods. You can further
     customize the callout's contents by implementing the
     `-mapView:calloutViewForAnnotation:` method.
     If the return value is `NO`, or if this method is absent from the delegate, or
     if the annotation lacks a title, the annotation will not show a callout even
     when selected.
     @param mapView The map view that has selected the annotation.
     @param annotation The object representing the annotation.
     @return A Boolean value indicating whether the annotation should show a
        callout.
     */
    func mapView(_ mapView: NGLMapView, annotationCanShowCallout annotation: NGLAnnotation) -> Bool{
        return true
    }
    
    /**
     Returns a callout view to display for the given annotation.
     If this method is present in the delegate, it must return a new instance of a
     view dedicated to display the callout. The returned view will be configured by
     the map view.
     If this method is absent from the delegate, or if it returns `nil`, a standard,
     two-line, bubble-like callout view is displayed by default.
     @param mapView The map view that requested the callout view.
     @param annotation The object representing the annotation.
     @return A view conforming to the `NGLCalloutView` protocol, or `nil` to use the
        default callout view.
     */
    func mapView(_ mapView: NGLMapView, calloutViewFor annotation: NGLAnnotation) -> NGLCalloutView? {
        return nil
    }
    
    /**
     Returns the view to display on the left side of the standard callout bubble.
     The left callout view is typically used to convey information about the
     annotation or to link to custom information provided by your application.
     If the view you specify is a descendant of the `UIControl` class, you can use
     the map view's delegate to receive notifications when your control is tapped,
     by implementing the `-mapView:annotation:calloutAccessoryControlTapped:`
     method. If the view you specify does not descend from `UIControl`, your view is
     responsible for handling any touch events within its bounds.
     If this method is absent from the delegate, or if it returns `nil`, the
     standard callout view has no accessory view on its left side. The return value
     of this method is ignored if `-mapView:calloutViewForAnnotation:` is present in
     the delegate.
     To display a view on the callout's right side, implement the
     `-mapView:rightCalloutAccessoryViewForAnnotation:` method.
     @param mapView The map view presenting the annotation callout.
     @param annotation The object representing the annotation with the callout.
     @return The accessory view to display.
     */
    func mapView(_ mapView: NGLMapView, leftCalloutAccessoryViewFor annotation: NGLAnnotation) -> UIView? {
        return nil
    }
    
    /**
     Returns the view to display on the right side of the standard callout bubble.
     The right callout view is typically used to convey information about the
     annotation or to link to custom information provided by your application.
     If the view you specify is a descendant of the `UIControl` class, you can use
     the map view's delegate to receive notifications when your control is tapped,
     by implementing the `-mapView:annotation:calloutAccessoryControlTapped:`
     method. If the view you specify does not descend from `UIControl`, your view is
     responsible for handling any touch events within its bounds.
     If this method is absent from the delegate, or if it returns `nil`, the
     standard callout view has no accessory view on its right side. The return value
     of this method is ignored if `-mapView:calloutViewForAnnotation:` is present in
     the delegate.
     To display a view on the callout's left side, implement the
     `-mapView:leftCalloutAccessoryViewForAnnotation:` method.
     @param mapView The map view presenting the annotation callout.
     @param annotation The object representing the annotation with the callout.
     @return The accessory view to display.
     */
    func mapView(_ mapView: NGLMapView, rightCalloutAccessoryViewFor annotation: NGLAnnotation) -> UIView? {
        return nil
    }
    
    /**
     Tells the user that the user tapped one of the accessory controls in the
     annotation's callout view.
     In a standard callout view, accessory views contain custom content and are
     positioned on either side of the annotation title text. If an accessory view
     you specify is a descendant of the `UIControl` class, the map view calls this
     method as a convenience whenever the user taps your view. You can use this
     method to respond to taps and perform any actions associated with that control.
     For example, if your control displays additional information about the
     annotation, you could use this method to present a modal panel with that
     information.
     If your custom accessory views are not descendants of the `UIControl` class,
     the map view does not call this method. If the annotation has a custom callout
     view via the `-mapView:calloutViewForAnnotation:` method, you can specify the
     custom accessory views using the `NGLCalloutView` protocol's
     `leftAccessoryView` and `rightAccessoryView` properties.
     @param mapView The map view containing the specified annotation.
     @param annotation The annotation whose accessory view was tapped.
     @param control The control that was tapped.
     */
    func mapView(_ mapView: NGLMapView, calloutAccessoryControlTapped control: UIControl){
        
    }
    
    /**
     Tells the user that the user tapped on an annotation's callout view.
     This method is called when the user taps on the body of the callout view, as
     opposed to the callout's left or right accessory view. If the annotation has a
     custom callout view via the `-mapView:calloutViewForAnnotation:` method, this
     method is only called whenever the callout view calls its delegate's
     `-[NGLCalloutViewDelegate calloutViewTapped:]` method.
     If this method is present on the delegate, the standard callout view's body
     momentarily highlights when the user taps it, whether or not this method does
     anything in response to the tap.
     @param mapView The map view containing the specified annotation.
     @param annotation The annotation whose callout was tapped.
     */
    func mapView(_ mapView: NGLMapView, tapOnCalloutFor annotation: NGLAnnotation){
        
    }
}

The code initializes a MapViewDelegateViewController class that subclasses UIViewController. It includes a property nbMapView of type NGLMapView, which represents a map view. The nbMapView property is configured in the configureMapView method, where the autoresizing mask is set and the delegate is assigned. In viewDidLoad, an instance of NGLMapView is created and assigned to nbMapView.

The code extends the MapViewDelegateViewController class to conform to the NGLMapViewDelegate protocol. It implements various delegate methods that provide information and respond to events related to the map view. These methods include:

  • mapView(_:didFinishLoading:): This method is called when the map view finishes loading its style. It creates a new camera object and sets it as the camera for the map view using the fly(to:completionHandler:) method.

  • mapView(_:shouldChangeFrom:to:): This method is called when the map view is about to change from the existing camera to a new camera. It can be used to determine whether the camera change should be allowed or not.

  • mapView(_:shouldChangeFrom:to:reason:): This method is similar to the previous one but provides additional information about the reason for the camera change.

  • mapView(_:regionWillChangeAnimated:) and mapView(_:regionWillChangeWith:animated:): These methods are called when the map view's viewpoint is about to change. They can be used to perform actions or update UI before the change occurs.

  • mapViewRegionIsChanging(_:) and mapView(_:regionIsChangingWith:): These methods are called while the map view's viewpoint is changing, either due to user interaction or animation. They can be used to track the ongoing changes in the viewpoint.

  • mapView(_:regionDidChangeAnimated:) and mapView(_:regionDidChangeWith:animated:): These methods are called when the map view's viewpoint has finished changing. They can be used to perform actions or update UI after the change has occurred.

  • Various other methods are implemented to handle events such as map loading, rendering, user location tracking, managing the appearance of annotations, etc. These methods provide customization options and allow the developer to respond to specific events related to the map view.

Overall, the code sets up a map view, configures its delegate, and implements delegate methods to control its behavior and respond to user interactions and map events.