• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Custom Map Camera Animation

This example shows how to customize the camera for NGLMapView. You can set the map camera or direction by use the following methods:

  • setCenter

  • setVisibleCoordinateBounds

  • setVisibleCoordinates

  • setCamera

  • fly

  • setDirection

  • setZoomLevel

docs-image

For all code examples, refer to Maps Code Examples

MapsCameraViewController view source

1import Foundation
2import UIKit
3import Nbmap
4enum CameraType{
5 case CameraSetCenterCoordinate
6 case CameraSetCenterCoordinateWithZoomLevel
7 case CameraSetCenterCoordinateWithZoomLevelAndDirection
8 case CameraSetCenterCoordinateWithZoomLevelAndDirectionCompletion
9 case SetZoomLevel
10 case SetDirection
11case SetVisibleCoordinateBounds
12 case SetVisibleCoordinateBoundsWithEdgePadding
13 case SetVisibleCoordinatesWithEdgePadding
14 case SetVisibleCoordinatesWithEdgePaddingAndDirectionAndDuration
15 case SetCamera
16 case SetCameraWithDuration
17 case SetCameraWithDurationAndCompletionHandler
18 case FlyToCamera

The given example demonstrates how to initialize a MapView and perform various operations on the nbMapView object.

Initializing MapView:

  • The code initializes a NGLMapView object called nbMapView in the viewDidLoad() method. It sets the frame of the map view to match the bounds of the current view controller's view.

Operations on nbMapView: The code includes a performeSettings(type:) method that performs different operations on the nbMapView based on the selected CameraType. The following operations are performed:

  • Camera Set Center Coordinate: Sets the center coordinate of the map view with optional animation.

  • Camera Set Center Coordinate with Zoom Level: Sets the center coordinate of the map view with a specific zoom level and optional animation.

  • Camera Set Center Coordinate with Zoom Level and Direction: Sets the center coordinate of the map view with a specific zoom level (18) and direction (180) and optional animation.

  • Camera Set Center Coordinate with Zoom Level, Direction, and Completion: Sets the center coordinate of the map view with a specific zoom level (18), direction (180), and optional animation, along with a completion handler.

  • Set Zoom Level: Sets the zoom level of the map view to 17 with optional animation.

  • Set Direction: Sets the direction (heading) of the map view to 0 with optional animation.

  • Set Visible Coordinate Bounds: Sets the visible coordinate bounds of the map view to a polygon defined by four coordinates, with optional animation.

  • **Set Visible Coordinate Bounds with Edge Padding:

  • **Sets the visible coordinate bounds of the map view to a polygon defined by four coordinates, with additional edge padding and optional animation.

  • Set Visible Coordinates with Edge Padding: Sets the visible coordinates of the map view to an array of coordinates, with additional edge padding and optional animation.

  • Set Visible Coordinates with Edge Padding, Direction, and Duration: Sets the visible coordinates of the map view to an array of coordinates, with additional edge padding, direction (160), duration (2 seconds), and optional animation.

  • Set Camera: Moves the viewpoint of the map to a different location specified by a NGLMapCamera object, with optional animation.

  • Set Camera with Duration: Moves the viewpoint of the map to a different location specified by a NGLMapCamera object, with a specific duration (1 second) and optional animation.

  • Set Camera with Duration and Completion Handler: Moves the viewpoint of the map to a different location specified by a NGLMapCamera object, with a specific duration (1 second), optional animation, and a completion handler.

  • Fly to Camera: Moves the viewpoint of the map to a different location specified by a NGLMapCamera object, using a transition animation that simulates powered flight.

  • Fly to Camera with Duration: Moves the viewpoint of the map to a different location specified by a NGLMapCamera object, using a transition animation that simulates powered flight, with a specific duration (2 seconds) and optional completion handler.

  • Fly to Camera with Duration and Peak Altitude: Moves the viewpoint of the map to a different location specified by a NGLMapCamera object, using a transition animation that simulates powered flight, with a specific duration (2 seconds), peak altitude (1000), and optional completion handler.

Have Questions ?