• Optimization
  • Navigation
  • Tracking
  • Maps
  • Places

Map Directions

This example shows how to configure a NGLMapView object. The NGLMapView object is a map view that can be used to display maps from the nominatim database. The NGLMapView allow to sets the following properties :

  • showsScale: This property is set to false to disable the scale bar.

  • scaleBarPosition: This property is set to .topLeft to position the scale bar at the top left of the map view.

  • scaleBarMargins: This property can be set to CGPoint to set the margins of the scale bar.

  • compassView.isHidden: This property can be set to true or false to show or hide the compass view.

  • compassViewMargins: This property can be set to CGPoint to set the margins of the compass view.

  • logoView.isHidden: This property can be set to true or false to show or hide the logo view.

  • logoViewMargins: This property can be set to CGPoint to set the margins of the logo view.

  • showsUserLocation: This property can be set to true or false to show or hide the user's location on the map.

  • userTrackingMode: This property can be set to .follow , .followWithHeading .followWithCourse or .none to make the map follow the user's location.

  • showsUserHeadingIndicator: This property can be set to true or false to enable or disable the user's heading indicator.

  • displayHeadingCalibration: This property can be set to true or false to show or hide the heading calibration alert when necessary.

  • targetCoordinate: This property can be set to the coordinate of the map's target.

  • isScrollEnabled: This property can be set to true or false to allow or disallow the user to scroll the map.

  • panScrollingMode: This property is set to .default to allow the user to scroll the map both horizontally and vertically.

  • isRotateEnabled: This property can be set to true or false to enable or disable the user's ability to rotate the map.

  • isPitchEnabled: This property can be set to true or false to allow or disallow the user to change the pitch of the map.

  • anchorRotateOrZoomGesturesToCenterCoordinate: This property can be set to true or false to enable or disable the anchoring of gestures to the center coordinate of the map while rotating or zooming.

Users can also use the following properties to get information from the NGLMapView object.

  • selectedAnnotations : Gets the selected annotations on the map.

  • visibleAnnotations: Gets the visible annotations that display on the map.

  • annotations : Gets all annotations added on the map.

  • visibleAnnotations: Gets the list of annotations associated with the receiver that intersect with the given rectangle.

  • zoomLevel: Gets the current zoom level of the map view.

  • Style: Gets the current map style.

  • userLocation: Gets the annotation object indicating the user's current location.

  • isRotateEnabled: Gets the bool value that determines whether the user may rotate the map, changing the direction.

  • isPitchEnabled: Gets the bool value that determines whether the user may change the pitch (tilt) of the map.

  • Direction: Gets the direction of the map.

For all code examples, refer to Maps Code Examples

MapConfigViewController view source

1import UIKit
2import Nbmap
3
4class MapConfigViewController: UIViewController, NGLMapViewDelegate {
5 var nbMapView: NGLMapView! {
6 didSet {
7 oldValue?.removeFromSuperview()
8 if let mapView = nbMapView {
9 configureMapView(nbMapView)
10 view.insertSubview(mapView, at: 0)
11 }
12 }
13 }
14
15 func configureMapView(_ mapView: NGLMapView) {
16 mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
17 /**
18 Set the map view's delegate.

Have Questions ?