Now, let’s see the other functionalities that could be performed.
Configuring Location updates
What if you want to set your own way of getting the location updates from the operator?
TripBuilder builder =newTripBuilder("Tracking_Id");builder.withInterval(5000); //Location update set to 5 seconds.builder.withDistance(10); //Location update set to 10 meters.Teliver.startTrip(builder.build());
You can also customize more with the method builder.withLocationRequest(locationrequest) Where you can pass the object of LocationRequest class of playservice.
Listeners for Trip
You can add listeners for the trips that you started by simply calling the below snippet.
Teliver.setTripListener(newTripListener() { @OverridepublicvoidonTripStarted(Trip tripDetails) {//This method is called when a trip has been started. } @OverridepublicvoidonLocationUpdate(Location location) {//This method is called when an location update is made. } @OverridepublicvoidonTripEnded(String trackingID) {//This method is called when a trip has been Ended. } @OverridepublicvoidonTripError(String reason) {//This method is called when a trip has faced error on starting. } });
Custom marker options
What if you want to set your own image, title and snippet for marker?
MarkerOption option =newMarkerOption("Tracking_Id");option.setMarkerTitle("Your_Title");option.setMarkerSnippet("Your_Snippet");option.setIconMarker(R.drawable.your_drawable); //You can also set your Bitmap object.Teliver.startTracking(newTrackingBuilder(option).withTitle("Track").build());
Note: withTitle() method here sets your page title on tracking page
This snippet enables the entire tracking system in order to take place in your own map object. Just pass the object created and you are done.
Get Location updates
What if you want just the location updates of each operator?
Teliver.startTracking(newTrackingBuilder(option).withListener(newTrackingListener(){@OverridepublicvoidonTrackingStarted(String trackingId) {//This method is called when the operator initiates the trip by startTrip method.}@OverridepublicvoidonLocationUpdate(String trackingId,TLocation location) {//This method is called when there is a updates in the location.}@OverridepublicvoidonTrackingEnded(String trackingId) {//This method is called when tracking has stopped by calling the method stopTracking.}@OverridepublicvoidonTrackingError(String reason) {//This method is called when there is error on tracking.}})).build());
Tag Location
What if you want to tag a particular location for future reference?
From your Operator app use the following snippet to tag a location of Operator.
Teliver.tagLocation("Tracking_Id","your order is delivered");