SPMapViewDelegate
Objective-C
@protocol SPMapViewDelegate
Swift
protocol SPMapViewDelegate
Extends MGLMapViewDelegate with Steerpath features.
-
Called when visible floor on the map will change to another floor.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView visibleFloorWillChange:(NSInteger)oldFloor newFloor:(NSInteger)newFloor building:(nonnull NSString *)building;
Swift
optional func mapView(_ mapView: SPMapView, visibleFloorWillChange oldFloor: Int, newFloor: Int, building: String)
Parameters
mapView
object that called this method
oldFloor
old floor index
newFloor
new floor index
building
unique identifier for building
-
Called when currently visible floor has changed.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView visibleFloorDidChange:(NSInteger)floor building:(nonnull NSString *)building;
Swift
optional func mapView(_ mapView: SPMapView, visibleFloorDidChange floor: Int, building: String)
Parameters
mapView
object that called this method
floor
new floor index
building
unique identifier for building
-
Called when a new building will be shown on the map.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView didShowBuilding:(nonnull NSString *)building floor:(NSInteger)floor;
Swift
optional func mapView(_ mapView: SPMapView, didShowBuilding building: String, floor: Int)
Parameters
mapView
object that called this method
building
unique identifier for building
-
Called when a building will be hidden/not visible on the map.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView didHideBuilding:(nonnull NSString *)building;
Swift
optional func mapView(_ mapView: SPMapView, didHideBuilding building: String)
Parameters
mapView
object that called this method
building
unique identifier for building
-
Called when user taps on map features.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView didSelectFeatures:(nonnull NSArray<id> *)features;
Swift
optional func mapView(_ mapView: SPMapView, didSelectFeatures features: [Any])
Parameters
mapView
object that called this method
features
list of map features where user tapped screen
-
Called when route instructions list has been either expanded or collapsed
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView didExpandRouteInstructions:(BOOL)isExpanded;
Swift
optional func mapView(_ mapView: SPMapView, didExpandRouteInstructions isExpanded: Bool)
Parameters
isExpanded
TRUE when the list is expanded
-
Called when navigation has calculated a route successfully. Will not be called when recalculation of the route is done automatically.
Declaration
Parameters
mapView
object the called this method
route
the route that was calculated
-
Called when navigation has calculated a route successfully and map is about to show the route overview.
By default overview will be shown.
Declaration
Parameters
mapView
object that called this method
route
the route for the overview
Return Value
true if overview should be shown
-
Called when navigation begins and step-by-step instructions appear. Will also be called when recalculation of the route was done automatically.
Declaration
Parameters
mapView
object that called this method
route
the route that will be navigated
-
Called when navigation ends.
Declaration
Parameters
mapView
object that called this method
route
the route that was being navigated
-
Called when attempting to navigate fails.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView navigationFailedWithError:(nonnull NSError *)error;
Swift
optional func mapView(_ mapView: SPMapView, navigationFailedWithError error: Error)
Parameters
mapView
object that called this method
error
describes reasons why navigation failed
-
Called when user has reached a location that was being navigated to. Be aware that if you use the ‘startNavigationThrough:’ method to start navigation, this delegate method will be called for each of the locations the user is navigating through.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView didNavigateToLocation:(nonnull SPLocation *)location;
Swift
optional func mapView(_ mapView: SPMapView, didNavigateTo location: SPLocation)
Parameters
mapView
object that called this method
location
one of the locations where user was navigating to.
-
Called when user has moved far enough from current route and a re-calculation of the navigation route will occur.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView willRecalculateRouteFrom:(nonnull SPLocation *)location;
Swift
optional func mapView(_ mapView: SPMapView, willRecalculateRouteFrom location: SPLocation)
Parameters
mapView
object that called this method
location
the location where user was last seen.
-
Called when user moves far enough from current route and a re-route should be made. You can prevent the re-route calculation by returning false/NO from this delegate method. By default a re-calculation will happen and you don’t have to implement this delegate method unless you have custom logic for re-route events.
Declaration
Objective-C
- (BOOL)mapView:(nonnull SPMapView *)mapView shouldRecalculateRouteFrom:(nonnull SPLocation *)location;
Swift
optional func mapView(_ mapView: SPMapView, shouldRecalculateRouteFrom location: SPLocation) -> Bool
Parameters
mapView
object that called this method
location
the location where user was last seen.
Return Value
true if re-calculation should happen
-
Called when user is navigating to inform the delegate of progress made on the navigation route. If you want to localize or modify the instructions provided by the SDK, download the Steerpath.strings file from https://steerpath.com/ios-indoor-positioning-sdk/ and include it into your project and make any changes you like.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView navigationInstructions:(nonnull NSString *)instructions progress:(nonnull NSString *)progress action:(SPRouteAction)action;
Swift
optional func mapView(_ mapView: SPMapView, navigationInstructions instructions: String, progress: String, action: SPRouteAction)
Parameters
mapView
object that called this method
instructions
for example ‘Walk 10m and turn right’
progress
overall distance and time from destination for example ‘724m to destination (~12min)’
action
specific action to take next
-
Called when user is navigating to inform the delegate of progress made on the navigation route. You can use this to create a list of navigation instructions. SPRouteStep objects have the method ‘instructions’ and ‘instructionsWith:’ that can be used to generate instructions list rows. If you want to localize or modify the instructions provided by the SDK, download the Steerpath.strings file from https://steerpath.com/ios-indoor-positioning-sdk/ and include it into your project and make any changes you like.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView navigatingRoute:(nonnull SPRoute *)route step:(nonnull SPRouteStep *)step distanceRemainingOnStep:(CGFloat)distance;
Swift
optional func mapView(_ mapView: SPMapView, navigatingRoute route: SPRoute, step: SPRouteStep, distanceRemainingOnStep distance: CGFloat)
Parameters
mapView
object that called this method
route
the current route that is being navigated
step
the current route step where user is on
distance
the remaining distance on the current step (in meters)
-
Called when a live user without a known title is detected on the map. Implement this delegate method to provide a title for a user. By default all live users will have the title ‘Live User’ over their map icon, implementing this method will replace that text.
The ‘userIdentifier’ corresponds to the values that you’re using in the SPLiveUserConfig/SPLiveUserInfo ‘userIdentifier’ property for each user.
Note that this method is called only once per user id. However if you return nil/null, this method will be called again when live user data is updated.
Declaration
Objective-C
- (nullable NSString *)mapView:(nonnull SPMapView *)mapView titleForLiveUser:(nonnull NSString *)userIdentifier;
Swift
optional func mapView(_ mapView: SPMapView, titleForLiveUser userIdentifier: String) -> String?
Parameters
mapView
object that called this method
userIdentifier
unique user identifier
-
Called when updated information has been received for live users on the map. This method will only return users that are in the group applied to the map via the SPLiveMapConfig.
Note that the ‘users’ array may be empty if no user information can be found.
You can find an example on how to sort users based on geofence here:
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView didUpdateLiveUsers:(nonnull NSArray<SPLiveUserInfo *> *)users;
Swift
optional func mapView(_ mapView: SPMapView, didUpdateLiveUsers users: [SPLiveUserInfo])
Parameters
mapView
object that called this method
users
list containing user information
-
Called when a new live user identifier is detected on the map.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView liveUserWillAppear:(nonnull NSString *)userIdentifier;
Swift
optional func mapView(_ mapView: SPMapView, liveUserWillAppear userIdentifier: String)
Parameters
mapView
object that called this method
userIdentifier
unique user identifier
-
Called when a live user will disappear from the map.
Declaration
Objective-C
- (void)mapView:(nonnull SPMapView *)mapView liveUserWillDisappear:(nonnull NSString *)userIdentifier;
Swift
optional func mapView(_ mapView: SPMapView, liveUserWillDisappear userIdentifier: String)
Parameters
mapView
object that called this method
userIdentifier
unique user identifier