SPMapView
Objective-C
@interface SPMapView
Swift
class SPMapView
Extends MGLMapView and provides additional functionality including but not limited to indoor maps, multi-floor routes, customizable floor widget, floor specific annotations etc.
To use this class you need to have a Steerpath API access token. See SPAccountManager.h for instructions on how to authenticate.
-
Delegate for SPMapView and MGLMapView callbacks
Declaration
Objective-C
@property (nonatomic, weak, nullable) id<SPMapViewDelegate> delegate;
Swift
@IBOutlet weak var delegate: SPMapViewDelegate? { get set }
-
Updates map view with configurations
Declaration
Objective-C
- (void)setConfig:(nonnull SPMapViewConfig *)config;
Swift
func setConfig(_ config: SPMapViewConfig)
Parameters
config
new map configuration
-
Return Value
current configuration
-
Add a custom view under the locate me button
Declaration
Objective-C
- (void)setCustomView:(nonnull UIView *)view;
Swift
func setCustom(_ view: UIView)
Parameters
view
the view that you want to add
-
Sets padding around the widgets in the map layout
Declaration
Objective-C
- (void)setWidgetPadding:(CGFloat)left top:(CGFloat)top right:(CGFloat)right bottom:(CGFloat)bottom;
Swift
func setWidgetPadding(left: CGFloat, top: CGFloat, right: CGFloat, bottom: CGFloat)
Parameters
left
left padding value
top
top padding value
right
right padding value
bottom
bottom padding value
-
Get current padding values of widgets
Declaration
Objective-C
- (nonnull NSArray<NSNumber *> *)getWidgetPadding;
Swift
func getWidgetPadding() -> [NSNumber]
Return Value
array of padding values in NSNumber: [left, top, right, bottom], which can be converted into CGFloat
-
Starts updating live users on the map according to configurations. If this is set to
nil
, the map won’t show any live users. This can be used to hide live users from the map view. What is a live user? See the class SPLive for more information.Declaration
Objective-C
- (void)showLiveUsersWithConfig:(nonnull SPLiveMapConfig *)config;
Swift
func showLiveUsers(with config: SPLiveMapConfig)
Parameters
config
the configurations for fetching live user data
-
Hides live users from map and stops requesting any updates to live user information.
What is a live user? See the class SPLive for more information.
Declaration
Objective-C
- (void)hideLiveUsers;
Swift
func hideLiveUsers()
-
Stores additional information for a live user. You can use this for example to set the title displayed on top of the user icon on the map.
Declaration
Objective-C
- (void)setLiveUserInfo:(nonnull NSString *)userIdentifier key:(nonnull NSString *)key value:(nonnull NSString *)value;
Swift
func setLiveUserInfo(_ userIdentifier: String, key: String, value: String)
Parameters
userIdentifier
unique identifier for the user
key
to use for storing the info
value
to store
-
Updates blue dot location on map. Will change visible building floor if the map is configured to automatically switch floors based on location.
Declaration
Objective-C
- (void)setCurrentLocation:(nonnull SPLocation *)location;
Swift
func setCurrentLocation(_ location: SPLocation)
Parameters
location
new location for user
-
Returns current location where user is according to the map. This may be nil if ‘setCurrentLocation’ has never been called or if user location has timed out (no location has been provided for 3 minutes)
Declaration
Objective-C
- (nullable SPLocation *)currentLocation;
Swift
func currentLocation() -> SPLocation?
Return Value
user location or nil
-
Zooms/centers the map to a location. If the location is an indoor location, the map will automatically show the correct floor.
Declaration
Objective-C
- (void)setCenterLocation:(nonnull SPLocation *)location zoomLevel:(CGFloat)zoomLevel animated:(BOOL)animated completion:(nullable void (^)(void))completionBlock;
Swift
func setCenter(_ location: SPLocation, zoomLevel: CGFloat, animated: Bool, completion completionBlock: (() -> Void)? = nil)
Parameters
location
to center on the map
zoomLevel
The new zoom level for the map.
animated
Specify
YES
if you want the map view to animate scrolling and zooming to the new location orNO
if you want the map to display the new location immediately.completionBlock
called after map center has changed.
-
Shows a specific floor. Does nothing if not currently viewing an indoor area for a building. Use this method if you want to force the map to change the visible floor to specific floor.
Above ground level: floor > 0
Ground level: floor == 0
Below ground level: floor < 0
Declaration
Objective-C
- (void)showFloor:(NSInteger)floor;
Swift
func showFloor(_ floor: Int)
Parameters
floor
the floor index to show
-
Shows a specific floor for a specific building. Has immediate effect if currently viewing the building. If not currently viewing the building, map view will open the floor when the building becomes visible.
Declaration
Objective-C
- (void)showFloor:(NSInteger)floor building:(nonnull NSString *)building;
Swift
func showFloor(_ floor: Int, building: String)
Parameters
floor
the floor index to show
building
unique identifier for building
-
Get the currently visible floor index. Will return 0 if no building is being viewed.
Declaration
Objective-C
- (NSInteger)visibleFloor;
Swift
func visibleFloor() -> Int
Return Value
floor index that is currently being shown on the map
-
This method returns a list of SPFloor objects if user is currently viewing a building that contains floor information. If there’s no floor information available, returns nil.
Return Value
list containing SPFloor objects in ascending order
-
Adds a route onto the map. Replaces old route if present. Currently supports drawing only one (1) route at a time.
It’s recommended to use the navigation methods instead of this.
Declaration
Objective-C
- (void)setRoute:(nonnull SPRoute *)route;
Swift
func setRoute(_ route: SPRoute)
Parameters
route
a route to draw on the map
-
Removes current route from the map.
Declaration
Objective-C
- (void)removeRoute;
Swift
func removeRoute()
-
Attempts to start navigation to a specific location. Starting location is the last user location passed onto map via ‘setCurrentLocation:’ method.
Listen to SPMapViewDelegate navigation callbacks to receive information about navigation related events.
When using this method, user location will be snapped to the navigation path. You can use the ‘stopNavigation’ method to manually stop navigation.
Declaration
Objective-C
- (void)startNavigationTo:(nonnull SPLocation *)destination;
Swift
func startNavigation(to destination: SPLocation)
Parameters
destination
target location for navigation.
-
Attempts to start navigation for a route that goes through a number of locations. Route will be calculated in the same order as the locations passed inside the array. Starting location is the last user location passed onto map via ‘setCurrentLocation:’ method.
Listen to SPMapViewDelegate navigation callbacks to receive information about navigation related events.
When using this method, user location will be snapped to the navigation path. You can use the ‘stopNavigation’ method to manually stop navigation.
Declaration
Objective-C
- (void)startNavigationThrough:(nonnull NSArray<SPLocation *> *)locations;
Swift
func startNavigationThrough(_ locations: [SPLocation])
Parameters
locations
list of locations to navigate through.
-
Attempts to start navigation route between two points.
Listen to SPMapViewDelegate navigation callbacks to receive information about navigation related events.
With this method you can define if navigation should track user on the navigation route. You can use the ‘stopNavigation’ method to manually stop navigation.
Declaration
Objective-C
- (void)startNavigationFrom:(nonnull SPLocation *)start to:(nonnull SPLocation *)destination trackProgress:(BOOL)track;
Swift
func startNavigation(from start: SPLocation, to destination: SPLocation, trackProgress track: Bool)
Parameters
start
location where navigation should start
destination
location where navigation should end
track
use NO if you don’t want to track user’s progress on route
-
Attempts to start navigation for a route that goes through a number of locations. Route will be calculated in the same order as the locations passed inside the array.
Declaration
Objective-C
- (void)startNavigationFrom:(nonnull SPLocation *)start through:(nonnull NSArray<SPLocation *> *)locations trackProgress:(BOOL)track;
Swift
func startNavigation(from start: SPLocation, through locations: [SPLocation], trackProgress track: Bool)
Parameters
start
location where navigation should start.
locations
list of locations to navigate through.
track
use NO if you don’t want to track user’s progress on route.
-
Attemps to start navigation from starting location through an list of possible waypoints.
Declaration
Objective-C
- (void)startMultiDestinationNavigationFrom:(nonnull SPLocation *)start possibleWaypoints: (nonnull NSArray<NSArray<SPLocation *> *> *) wayPoints;
Swift
func startMultiDestinationNavigation(from start: SPLocation, possibleWaypoints wayPoints: [[SPLocation]])
Parameters
start
location where navigation should start.
wayPoints
possible waypoints list. The format should look like this: [[Waypoint1, Waypoint2, Waypoint3], [Waypoint4, Waypoint5], [Waypoint6, Waypoint7], [Waypoint8]]
-
Declaration
Objective-C
- (BOOL)isNavigating;
Swift
func isNavigating() -> Bool
Return Value
true if map is currently in navigation mode
-
Stops navigation and navigation preview. Removes navigation route from map. If you want to temporarily pause the navigation, use the ‘pauseNavigation’ method.
Declaration
Objective-C
- (void)stopNavigation;
Swift
func stopNavigation()
-
Pauses navigation. This will hide the navigation bar and prevent any re-routes from occurring. If you want to completely stop navigation, use the ‘stopNavigation’ method.
Declaration
Objective-C
- (void)pauseNavigation;
Swift
func pauseNavigation()
-
Resumes navigation. This will show the navigation bar and enable normal navigation behaviour.
Declaration
Objective-C
- (void)resumeNavigation;
Swift
func resumeNavigation()
-
Adds an annotation to a specific floor.
Declaration
Objective-C
- (void)addAnnotation:(nonnull id)annotation floor:(nullable NSNumber *)floor;
Swift
func addAnnotation(_ annotation: Any, floor: NSNumber?)
Parameters
annotation
object to add onto map
floor
index or nil if annotation should always be visible
-
Adds a list of annotations to a specific floor
Declaration
Objective-C
- (void)addAnnotations:(nonnull NSArray<id> *)annotations floor:(nullable NSNumber *)floor;
Swift
func addAnnotations(_ annotations: [Any], floor: NSNumber?)
Parameters
annotations
list of objects to add onto map
floor
index or nil if annotation should always be visible
-
Removes an annotation from map.
Declaration
Objective-C
- (void)removeAnnotation:(nonnull id)annotation;
Swift
func removeAnnotation(_ annotation: Any)
Parameters
annotation
object to remove from map
-
Removes a list of annotations from map.
Declaration
Objective-C
- (void)removeAnnotations:(nonnull NSArray<id> *)annotations;
Swift
func removeAnnotations(_ annotations: [Any])
Parameters
annotations
list of objects to remove from map
-
Removes all annotations from map
Declaration
Objective-C
- (void)removeAllAnnotations;
Swift
func removeAllAnnotations()
-
Generates/reuses an annotation view for an annotation. This will use the default views provided by the SDK. (see SPAnnotationView.h)
Declaration
Objective-C
- (nullable SPAnnotationView *)dequeueAnnotationViewForAnnotation: (nonnull id)annotation;
Swift
func dequeueAnnotationView(forAnnotation annotation: Any) -> SPAnnotationView?
Parameters
annotation
object used for finding a reusable view
Return Value
SPAnnotationView annotation view
-
Deprecated
This method is deprecated and will be removed completely in an upcoming version.
Highlights annotation on the map. Plays a default animation. This method only works if you are using the default annotation views provided by the SDK. (see SPAnnotationView.h)
Declaration
Objective-C
- (void)highlightAnnotation:(nonnull id)annotation;
Swift
func highlightAnnotation(_ annotation: Any)
Parameters
annotation
object to highlight on map
-
Highlights the the object in a specific building.
Declaration
Objective-C
- (void)highlight:(nonnull NSString *)localRef buildingRef:(nonnull NSString *)buildingRef;
Swift
func highlight(_ localRef: String, buildingRef: String)
Parameters
localRef
identifier for the point of interest. Corresponds to the ‘localRef’ property in the map data.
buildingRef
unique identifier for the building
-
Clears all highlights on the map.
Declaration
Objective-C
- (void)clearHighlights;
Swift
func clearHighlights()
-
Shows location info sheet on the bottom of the map view if the ‘SPMapViewConfig’ property ‘showsLocationInfoBar’ is enabled. Note that the SPLocation property ‘info’ is used as the text to display
Declaration
Objective-C
- (void)showLocationInfo:(nonnull SPLocation *)location;
Swift
func showLocationInfo(_ location: SPLocation)
Parameters
location
containing information. Used as a destination if the user clicks the navigation button in the info sheet.