Route serialization is a feature that allows users to use the new
serializedRouteWithError: to serialize a route into
NSData, which can then be saved as a file. Using the new
routeFromSerializedRoute:error method, a route can be generated from a previously serialized route without going through the route calculation process. This is useful when a user would like to recover from a crash during navigation or when a user would like to transfer a route from one device to another.
Route serialization currently only supports car, bike, pedestrian, and truck routes. Public Transit, Indoor Venue, and Urban Mobility routes cannot be serialized. Route serialization also does not work when the map version from which a route is serialized does not match the current map version. Route serialization also fails if the binary data containing the serialized route is tempered with or corrupted. In these cases, a specific
NMARouteSerializationError error code is returned.
The following is an example of how to invoke the serialization APIs:
NMARoute route; //assume that route calculation was already performed NSData *data; NSError *error; // serialize data = [route serializedRouteWithError:&error]; // deserialize route = [NMARoute routeFromSerializedRoute:data error:&error];