GLRouteRequest
Objective-C
@interface GLRouteRequest : NSObject
Swift
class GLRouteRequest : NSObject
GLRouteRequest is a class that constructs and sends route requests, either offline or online, and provides information about the route.
-
Default initializer.
Declaration
Objective-C
- (nonnull instancetype)init;Swift
init()Return Value
A new request instance.
-
User-defined request. You should pass correct request in JSON format. See reference at: https://valhalla.github.io/valhalla/api/turn-by-turn/api-reference/
{ "locations": [ { "lat": 42.358528, "lon": -83.2714, "street": "Appleton" }, { "lat": 42.996613, "lon": -78.749855, "street": "Ranch Trail" } ], "costing": "auto", "costing_options": { "auto": { "country_crossing_penalty": 2000 } }, "directions_options": { "units": "miles" }, "id": "my_work_route" }Declaration
Objective-C
- (nonnull instancetype)initWithJSON:(nonnull NSString *)json startPoint:(GLMapGeoPoint)startPoint;Swift
convenience init(json: String, start startPoint: GLMapGeoPoint)Parameters
jsonRequest in JSON format.
startPointStart point of the route (used to optimize offline navigation data lookup).
Return Value
A new request instance.
-
Starts an online request.
Declaration
Objective-C
- (int64_t)startOnlineWithCompletion: (nonnull GLRouteRequestCompletionBlock)completion;Swift
func startOnline(completion: @escaping GLRouteRequestCompletionBlock) -> Int64Parameters
completionA block that is called when the request completes.
Return Value
Request ID that can be used with
+[GLRouteRequest cancel:]. -
Starts an offline request.
Declaration
Objective-C
- (int64_t)startOfflineWithConfig:(nonnull NSString *)config completion: (nonnull GLRouteRequestCompletionBlock)completion;Swift
func startOffline(withConfig config: String, completion: @escaping GLRouteRequestCompletionBlock) -> Int64Parameters
configContents of the configuration file for the Valhalla routing engine. See valhalla.json inside the demo app.
completionA block that is called when the request completes.
Return Value
Request ID that can be used with
+[GLRouteRequest cancel:]. -
Starts a synchronous offline request.
Declaration
Objective-C
+ (NSString *_Nullable)offlineAction:(nonnull NSString *)action request:(nonnull NSString *)request config:(nonnull NSString *)config startPoint:(GLMapGeoPoint)startPoint error:(NSError *_Nullable *_Nullable)error;Swift
class func offlineAction(_ action: String, request: String, config: String, start startPoint: GLMapGeoPoint) throws -> StringParameters
actionValhalla action (e.g. route, optimized_route, …)
requestJSON string with the request
configContents of the configuration file for the Valhalla routing engine. See valhalla.json inside the demo app.
startPointstart point of the route. It’s used to optimize navigation data lookup in offline requests.
errorerror
Return Value
result of request
-
Cancels a request that was started.
Declaration
Objective-C
+ (void)cancel:(int64_t)requestID;Swift
class func cancel(_ requestID: Int64)Parameters
requestIDID of the request to cancel.
-
Adds a route point (location) to the request.
Parameters
pointPoint to add (in geographic coordinates).
-
Adds a location to exclude or avoid.
Declaration
Objective-C
- (void)addExcludeLocation:(GLRoutePoint)point;Swift
func addExcludeLocation(_ point: GLRoutePoint)Parameters
pointPoint to avoid (in geographic coordinates).
-
Roads intersecting this polygon will be avoided during path finding. If you only need to avoid a few specific roads, it’s much more efficient to use exclude locations.
Declaration
Objective-C
- (void)addExcludePolygon:(nonnull GLMapGeoPoint *)points count:(NSUInteger)count;Swift
func addExcludePolygon(_ points: UnsafeMutablePointer<GLMapGeoPoint>, count: UInt)Parameters
pointspoints of polygon exterior ring
countnumber of points
-
Sets the local date and time at the departure/arrival location.
Declaration
Objective-C
- (void)setDateTime:(nonnull NSString *)date type:(GLRouteDateTimeType)type;Swift
func setDateTime(_ date: String, type: GLRouteDateTimeType)Parameters
datethe date and time is specified in ISO 8601 format (YYYY-MM-DDThh:mm) in the local time zone of departure or arrival. For example “2016-07-03T08:06”
typetype of date and time
-
Sets the request ID. If set, it is forwarded to the routing engine response.
Declaration
Objective-C
- (void)setRequestID:(nonnull NSString *)requestID;Swift
func setRequestID(_ requestID: String)Parameters
requestIDRequest identifier string.
-
Sets routing mode and uses default options for it.
Declaration
Objective-C
- (void)setModeWithDefaultOptions:(GLRouteMode)mode;Swift
func setModeWithDefaultOptions(_ mode: GLRouteMode)Parameters
moderouting mode
-
Sets navigation mode to auto
Declaration
Objective-C
- (void)setAutoWithOptions:(CostingOptionsAuto)options;Swift
func setAutoWithOptions(_ options: CostingOptionsAuto)Parameters
optionsoptions
-
Sets navigation mode to cycle
Declaration
Objective-C
- (void)setBicycleWithOptions:(CostingOptionsBicycle)options;Swift
func setBicycleWithOptions(_ options: CostingOptionsBicycle)Parameters
optionsoptions
-
Sets navigation mode to walk
Declaration
Objective-C
- (void)setPedestrianWithOptions:(CostingOptionsPedestrian)options;Swift
func setPedestrianWithOptions(_ options: CostingOptionsPedestrian)Parameters
optionsoptions
-
Sets navigation mode to straight
Declaration
Objective-C
- (void)setStraightWithOptions:(CostingOptionsStraight)options;Swift
func setStraightWithOptions(_ options: CostingOptionsStraight)Parameters
optionsoptions
-
Sets navigation mode to bus
Declaration
Objective-C
- (void)setBusWithOptions:(CostingOptionsAuto)options;Swift
func setBusWithOptions(_ options: CostingOptionsAuto)Parameters
optionsoptions
-
Sets navigation mode to bikeshare
Declaration
Objective-C
- (void)setBikeshareWithOptions:(CostingOptionsBicycle)options;Swift
func setBikeshareWithOptions(_ options: CostingOptionsBicycle)Parameters
optionsoptions
-
Sets navigation mode to truck
Declaration
Objective-C
- (void)setTruckWithOptions:(CostingOptionsTruck)options;Swift
func setTruckWithOptions(_ options: CostingOptionsTruck)Parameters
optionsoptions
-
Sets navigation mode to taxi
Declaration
Objective-C
- (void)setTaxiWithOptions:(CostingOptionsAuto)options;Swift
func setTaxiWithOptions(_ options: CostingOptionsAuto)Parameters
optionsoptions
-
Sets navigation mode to scooter
Declaration
Objective-C
- (void)setMotorScooterWithOptions:(CostingOptionsMotorScooter)options;Swift
func setMotorScooterWithOptions(_ options: CostingOptionsMotorScooter)Parameters
optionsoptions
-
Sets navigation mode to motorcycle
Declaration
Objective-C
- (void)setMotorcycleWithOptions:(CostingOptionsMotorcycle)options;Swift
func setMotorcycleWithOptions(_ options: CostingOptionsMotorcycle)Parameters
optionsoptions
-
If
YES, the order of intermediate points may be changed to optimize the route. Default isNO.Declaration
Objective-C
@property BOOL optimize;Swift
var optimize: Bool { get set } -
Routing mode. Default is
GLRouteMode_Auto. -
Unit system for instructions. Default is
GLUnitSystem_International.Declaration
Objective-C
@property GLUnitSystem unitSystem;Swift
var unitSystem: GLUnitSystem { get set } -
Locale for instructions. Default is the first value from
+[NSLocale preferredLanguages].Declaration
Objective-C
@property (strong) NSString *_Nonnull locale;Swift
var locale: String { get set } -
Current request JSON string.
Declaration
Objective-C
@property (readonly) NSString *_Nonnull json;Swift
var json: String { get } -
A number denoting how many alternate routes should be provided. There may be no alternates or fewer alternates than the user specifies. Alternates are not yet supported on multipoint routes (that is, routes with more than 2 locations). They are also not supported on time dependent routes. Default is 2.
Declaration
Objective-C
@property NSInteger alternates;Swift
var alternates: Int { get set }
Install in Dash