A callback is a method that is called at a particular time in the code, often
for logging purposes. An outside application can create listeners that detect
when these methods are called, and act accordingly by defining the methods. A
hook is the same as a callback, but also demands that a value be returned from
the outside application when detected by the listener. This allows communication
between CoPilot and the software that is integrating it.
Called when CoPilot has finished shutting down. We recommend that you shut down the service only when necessary. It is also best to wait at least 2 or 3 seconds to restart CoPilot after you shut it down. Restarting too frequently or too quickly can cause the application to crash.
onMinimize() (Android only)
Method JavaScript:
onMinimize= () => {}
Type:
Callback
Description:
Called when the user presses the back button in the CoPilot navigation dialog.
onFavoriteAdded()
Method JavaScript:
onFavoriteAdded= () => {}
Type:
Callback
Description:
Called when a Favorite is added to CoPilot.
onFavoriteEdited()
Method JavaScript:
onFavoriteEdited= () => {}
Type:
Callback
Description:
Called when a Favorite is edited in CoPilot.
onFavoriteDeleted()
Method JavaScript:
onFavoriteDeleted= () => {}
Type:
Callback
Description:
Called when a Favorite is deleted in CoPilot.
onMapStopClicked
Method JavaScript:
onMapStopClicked= (stopClicked) => {}
Type:
StopClickInfo
Data Type:
JSON object
Description:
Called whenever the user clicks on the destination or waypoint on the map.
onMapPOIClicked()
Method JavaScript:
onMapPOIClicked= (list) => {}
Type:
Array of POISearchResult
Data Type:
JSON Array
Description:
Returns a list of POISearchResult that represents the POIs at the clicked location.
onMapSelectionCleared()
Method JavaScript:
onMapSelectionCleared= () => {}
Type:
Callback
Description:
Called when the user has clicked on the map in one of two situations: 1. The user had previously clicked on the map to select a POI, Road, or Stop, and the user clicks on the map off of that, which would clear the selection. 2. The user has clicked on the map in a location where there is no selection.
onSingleSearchFinished()
Callback Data:
“stopList”: Array of Stop JSON objects “Error”: SingleSearchError object
Data Type:
JSON Object
Description:
Called when a single search web service gives back the response and gives a list of Stops and SingleSearchError result.
onSingleSearchReady()
Method JavaScript:
onSingleSearchReady= () => {}
Type:
Callback
Description:
Called when single search has finished initializing
Called whenever a stop is on a pedestrian only road link.
onEnvironmentalZone()
Method JavaScript:
onEnvironmentalZone= (environmentalZones) => {}
Callback Data:
Array of EnvironmentalZoneType JSON
Data Type:
JSON object
Description:
Called whenever a stop or a route passes through the London congestion zone, Environment Zone or ULEZ zone. It is called when CoPilot identifies a road or destination as truck restricted.
onTruckRestricted()
Method JavaScript:
onTruckRestricted= (truckRestrictionType) => {}
Callback Data:
TruckRestrictionType constant
Data Type
Constant
Description:
Called when a driver is on a truck-restricted, commercial-prohibited, or hazmat-restricted road; or a width/length/height/weight restricted road; or a stop is located on one of those types of restricted roads.
onTrafficAlert()
Method JavaScript:
onTrafficAlert= (trafficAlertInfo) => {}
Callback Data:
TrafficAlertInfo JSON object
Data Type
JSON object
Description:
Called in the following scenarios: 1. A delay due to traffic with alternate route info. 2. Road closure 3. A sudden slowdown in a few miles that warns the driver to use caution.
onSafetyCamUpdate()
Method JavaScript:
onSafetyCamUpdate= (safetyCam) => {}
Callback Data:
SafetyCamera JSON object
Data Type
JSON object
Description:
Called when new guidance safety camera information is available. NOTE: This API requires the CoPilot library to be licensed for Basic Navigation.
Called when there was an error processing a RouteSync route. This callback will also fire if there were any errors processing a saved managed route when CPIK starts. These events can be captured by listeners that are registered before starting the CoPilot service.
onRouteSyncIntegrated()
Method JavaScript:
onRouteSyncIntegrated= (routeName) => {}
Callback Data:
A String containing the route name.
Data Type
String
Description:
Called after a routesync route has successfully been integrated.
onOutOfRoute()
Method JavaScript:
onOutOfRoute= (cbData) => {}
Callback Data:
timeOfDeviation: Date object containing the date and time of when the driver deviated from the prescribed route pointOfDeviation: RouteSyncLocation JSON object containing the point at which the driver deviated from the route.
Data Type
JSON Object
Description:
Called when Copilot detects that the device is out of route.
onRejoinRoute()
Method JavaScript:
onRejoinRoute= (cbData) => {}
Callback Data:
timeOfRejoin: Date object containing the date and time of when the driver rejoin the prescribed route. pointOfRejoin: RouteSyncLocation JSON object containing the point at which the driver rejoined the route. outOfRouteDistanceTraveled: Double containing the distance traveled while out of route.
Data Type
JSON Object
Description:
Called when Copilot detects that the device has rejoined the route. Contains data concerning the duration and distance traveled while out of route.
onStartAlternateRouteCalculation()
Method JavaScript:
onStartAlternateRouteCalculation= () => {}
Type
Callback
Description:
Called when an alternate route calculation starts in CoPilot.
onAlternateRouteSelected()
Method JavaScript:
onAlternateRouteSelected= (tripID) => {}
Callback Data:
Int containing the TripID of the selected route.
Data Type
Integer
Description:
Called when user selects the alternate route in the alternate route dialog.
onRouteCalculation()
Method JavaScript:
onRouteCalculation= (alternateRouteInfo) => {}
Callback Data:
AlternateRouteInfo JSON object
Data Type
JSON Object
Description:
Called when CoPilot calculates the base route and alternate routes or when CoPilot finds a traffic delay for the base route and calculates an alternate route.
This Callback is called whenever the GPS fix has been acquired, lost or changed.
onReadyToAddStops
Method JavaScript:
onReadyToAddStops= () => {}
Type:
Callback
Description:
This callback is only called at startup when CoPilot is ready to add stops. It will not be called each time you add a new stop to your trip. However, if there is an existing route already in CoPilot, this callback will be fired when you re-launch CoPilot.
Called when one or more stops have been added to the current trip. If a trip exists and then a new trip is planned, onStopsDeleted() is called, followed by onStopsAdded()
onStopsDeleted will be called if stops are successfully deleted. The callback also returns a list of stops that were deleted. For RouteMgr.deleteStop, the returned stop list should only have one element. But for RouteMgr.removeAllStops, the return stop list can have more than one elements.
Callback is provided when a user has registered a GuidanceListener with the onArrivedAtStop class. Uses the native module ArrivalStatus, to provide status details of the stop.
The approaching and arrival status messages are controlled by a set of configuration values that can be set within the product/user configuration file.
[User Settings] “ApproachingStopDistHundredths”, and “ArrivedStopDistHundredths” options both indicate the distance threshold, in hundredths of a mile, from your stop, where the user will see the prompt (popup, sound, or speech) to be shown.
The defaults are:
If you would like the Arrived prompt, it is recommended to prompt at 1 or 2 hundredths of a mile (50 or 100 feet from the stop). “ArrivedStopDistHundredths“=1 or 2
[GPS] “SpeakApproachingDestinationInstr”, “SpeakArrivedAtDestinationInstr”, “PlayArrivedAtDestinationSound”, “PlayApproachingDestinationSound” can be used to modify how CoPilot indicates “Approaching or Arrived” status (whether prompted with Text To Speech, sound, or no prompt). The onArrivedAtStop callback will fire regardless of these settings. If they are all accidentally set to on, the Speech announcement will prompt.
[User Settings] “ShowArrivalPopup” can be used to request CoPilot DOES NOT show the Arrival Popup. Showing or not showing the popup, does NOT have any affect on whether or not the status event is fired through CPIK libraries.
Called when new guidance information is available.
onTrafficInfoProcessedForCurrentRoute
Method JavaScript:
onTrafficInfoProcessedForCurrentRoute = () => {}
Type:
Callback
Description:
Called when traffic information is received and processed from the traffic server for the current route. The customer application gets the ETA as well traffic delay information by using RouteMgr.getRouteLegs().get(0).getETA() and RouteMgr.getRouteLegs().get(0).getTrafficDelay() respectively.
Called when a driver’s stop’s status changes (e.g OnTime to Late). The callback will return a list of stops who status have been changed.
GeofenceListener
Callbacks related to GeofenceMgr
onGeofenceEntry
Method JavaScript:
onGeofenceEntry = (callbackData) => {}
Callback Data:
“geofence”: Geofence “position”: Coordinate “time”: Date
Data Type:
JSON Object
Description:
Called when the current position enters a geofence that has an entry notification sent. Contains details on the geofence that was entered, the position at which the geofence was entered, and the time at which the geofence was entered.
onGeofenceExit
Method JavaScript:
onGeofenceExit = (callbackData) => {}
Callback Data:
“geofence”: Geofence “position”: Coordinate “time”: Date
Data Type:
JSON Object
Description:
Called when the current position leaves a geofence that has an exit notification sent. Contains details on the geofence that was exited, the position at which the geofence was exited, and the time at which the geofence was exited.
onGeofenceRouteThrough
Method JavaScript:
onStopsDeleted = (stops) => {}
Callback Data:
Array of Geofence JSON Objects
Data Type:
JSON Array
Description:
Called when a route is calculated which passes through any geofences which have the route through notification set.
Called when CoPilot has started a MapSure sync in response to a call to the API getMapSureOverride().
onMapSureOverrideSyncFailed
Method JavaScript:
onMapSureOverrideSyncFailed = () => {}
Type:
Callback
Description:
Called when CoPilot has triggered a MapSure sync in response to a call to the API getMapSureOverride() but it has failed.
onMapSureOverrideSyncSuccess
Method JavaScript:
onMapSureOverrideSyncSuccess = (cbData) => {}
Callback Data:
“successful”: int “failed”: int
Data Type:
JSON Object
Description:
Provides notification that a MapSure Override sync has completed and it includes the number of edits that have been successfully updated and the number that have failed
Called to provide Optimization result once Optimization finished. It will provide final ETA, total distance as well individual stop’s optimization number, ETA and distance.
Called when the navigation screen (map) is hidden.
onStartingPoiWizard()
Method JavaScript:
onStartingPoiWizard= () => {}
Type:
Callback
Description:
Called when the Points of Interest (POI) search wizard is about to start. This is called from both the driving menu (from the navigation screen) and the main menu.