GPXMapView
class GPXMapView : MKMapView
A MapView that Tracks user position
- it is able to convert GPX file into map
- it is able to return a GPX file from map
Some definitions
- A track is a set of segments.
- A segment is set of points. A segment is linked to a MKPolyline overlay in the map. Each time the user touches “Start Tracking” => a segment is created (currentSegment) Each time the users touches “Pause Tracking” => the segment is added to trackSegments When the user saves the file => trackSegments are consolidated in a single track that is added to the file. If the user opens the file in a session for the second, then tracks some seg ments and saves the file again, the resulting gpx file will have two tracks.
-
Current session of GPX location logging. Handles all background tasks and recording.
Declaration
Swift
let session: GPXSession
-
The line being displayed on the map that corresponds to the current segment.
Declaration
Swift
var currentSegmentOverlay: MKPolyline
-
Declaration
Swift
var extent: GPXExtentCoordinates
-
position of the compass in the map Example: map.compassRect = CGRect(x: map.frame.width/2 - 18, y: 70, width: 36, height: 36)
Declaration
Swift
var compassRect: CGRect
-
Is the map using local image cache??
Declaration
Swift
var useCache: Bool { get set }
-
Arrow image to display heading (orientation of the device) initialized on MapViewDelegate
Declaration
Swift
var headingImageView: UIImageView?
-
Selected tile server.
See also
GPXTileServerDeclaration
Swift
var tileServer: GPXTileServer { get set }
-
Overlay that holds map tiles
Declaration
Swift
var tileServerOverlay: MKTileOverlay
-
Declaration
Swift
let coreDataHelper: CoreDataHelper
-
Heading of device
Declaration
Swift
var heading: CLHeading?
-
Offset to heading due to user’s map rotation
Declaration
Swift
var headingOffset: CGFloat?
-
Gesture for heading arrow to be updated in realtime during user’s map interactions
Declaration
Swift
var rotationGesture: UIRotationGestureRecognizer
-
Initializes the map with an empty currentSegmentOverlay.
Declaration
Swift
required init?(coder aDecoder: NSCoder)
-
Override default implementation to set the compass that appears in the map in a better position.
Declaration
Swift
override func layoutSubviews()
-
hides apple maps stuff when map tile != apple.
Declaration
Swift
func updateMapInformation(_ tileServer: GPXTileServer)
-
Handles rotation detected from user, for heading arrow to update.
Declaration
Swift
@objc func rotationGestureHandling(_ gesture: UIRotationGestureRecognizer)
-
Adds a waypoint annotation in the point passed as arguments
For example, this function can be used to add a waypoint after long press on the map view
Declaration
Swift
func addWaypointAtViewPoint(_ point: CGPoint)
Parameters
point
The location in which the waypoint has to be added.
-
Adds a waypoint to the map.
Declaration
Swift
func addWaypoint(_ waypoint: GPXWaypoint)
-
Removes a Waypoint from the map
Declaration
Swift
func removeWaypoint(_ waypoint: GPXWaypoint)
-
Updates the heading arrow based on the heading information
Declaration
Swift
func updateHeading()
-
Adds a new point to current segment.
Declaration
Swift
func addPointToCurrentTrackSegmentAtLocation(_ location: CLLocation)
Parameters
location
Typically a location provided by CLLocation
-
If current segmet has points, it appends currentSegment to trackSegments and initializes currentSegment to a new one.
Declaration
Swift
func startNewTrackSegment()
-
Finishes current segment.
Declaration
Swift
func finishCurrentSegment()
-
Clears map.
Declaration
Swift
func clearMap()
-
Converts current map into a GPX String
Declaration
Swift
func exportToGPXString() -> String
-
Sets the map region to display all the GPX data in the map (segments and waypoints).
Declaration
Swift
func regionToGPXExtent()
-
Imports GPX contents into the map.
Declaration
Swift
func importFromGPXRoot(_ gpx: GPXRoot)
Parameters
gpx
The result of loading a gpx file with iOS-GPX-Framework.
-
Declaration
Swift
private func addWaypoints(for gpx: GPXRoot, fromImport: Bool = true)
-
Declaration
Swift
private func addTrackSegments(for gpx: GPXRoot)
-
Declaration
Swift
func continueFromGPXRoot(_ gpx: GPXRoot)