Mappls Tracking Widget¶
Getting started¶
This advanced tracking plugin, offered by Mappls plugins for android, allows one to track the path traveled with smooth animation along the route. The smooth animation by plugin directly depend upon the frequency of the provided information on the current location, time, and speed of the vehicle being tracked to the plugin. More the Merrier!
Add the dependency¶
- Add below dependency in your app-level build.gradle
Kotlin (build.gradle.kts)¶
implementation 'com.mappls.sdk:mappls-tracking-plugin:1.0.0'
Groovy (build.gradle)¶
implementation 'com.mappls.sdk:mappls-tracking-plugin:1.0.0'
Add MapplsTrackingWidget¶
Kotlin¶
val trackingOption = TrackingOption.Builder(
origin = Point.fromLngLat(77.26890561043258, 28.550947419414012),
destination = Point.fromLngLat(77.25988209737588, 28.55373960502866),
riderIcon = AppCompatResources.getDrawable(this, R.drawable.bikeicon)!!,
destinationIcon = AppCompatResources.getDrawable(this, R.drawable.marker)!!,
originIcon = AppCompatResources.getDrawable(this, R.drawable.marker)!!,
lineColor = Color.BLUE,
directionRouteType = DirectionsCriteria.ROUTE_TYPE_SHORTEST,
directionResource = DirectionsCriteria.RESOURCE_ROUTE,
)
mapplsTrackingManager = MapplsTrackingManager(mBinding.mapView, mapplsMap, trackingOption.build())
mapplsTrackingManager?.setOnSegmentCompleteListener { data ->
Log.d("formattedJson", Gson().toJson(data))
}
Java¶
TrackingOption trackingOption = new TrackingOption.Builder(Point.fromLngLat(77.26890561043258, 28.550947419414012), Point.fromLngLat(77.25988209737588, 28.55373960502866))
.build();
// Create MapplsTrackingManager
MapplsTrackingManager mapplsTrackingManager =
new MapplsTrackingManager(mBinding.mapView, mapplsMap, trackingOption);
// Set the segment complete listener
mapplsTrackingManager.setOnSegmentCompleteListener(new Function1<TrackingData, Unit>() {
@Override
public Unit invoke(TrackingData trackingData) {
Log.d("formattedJson", new Gson().toJson(trackingData));
return Unit.INSTANCE; // <- required
}
});
Mandatory Request Properties¶
origin(Point): route start location . For eg - { Point.fromLngLat(77.26890561043258, 28.550947419414012) }destination(Point): route end location . For eg - { Point.fromLngLat(77.25988209737588, 28.55373960502866)}
Request Parameters¶
lineColor(Int): To set a lineColor for route draw.connectorLineColor(Int): To set a color for draw a connector line from the last point of a route on the road to the actual input destination coordinate.enableConnectorLine(Boolean): To set boolean value for hide/show connector line from the last route point on road to actual input destination coordinate // default falselineWidth(Float): To set a width of route line.iconSize(Float): To set a iconSize of originIcon,riderIcon & destinationIcon.directionRouteType(Int): To set the routeType. Default to "DirectionsCriteria.ROUTE_TYPE_SHORTEST".destinationIcon(Drawable): To set destination icon.originIcon(Drawable): To set origin icon set.riderIcon(Drawable): To set rider icon set.directionResource(String): To set the route resource. Default to "route_eta".routeChangeBuffer(Int): The distance defined for call reroute for the provided current location.polylineRefresh(Boolean): To remove the route at the same time as the rider progresses along the route.latentViz(LatentViz): To set the string value for smooth visualization when rider suddenly jumps off-route. Incurs an additional routing call.// [Acceptable values for this is : jump,fly & route]-
latentVizRadius(Int): -
animationSpeed(Long): This value is speed in metres/sec at which the rider simulation will be started at. The ride simulation will be slowed at a defined rate below this speed after every few metres to enable a very smooth and slow animation till the time a fresh active location is injected tot the widget or max simulation distance is reached. fakeSimDistance(Int): To set the fake animation distance.fakeSpeedMetersPerSecond(Int): To set the fake animation speed in MetersPerSecond.viaPoints( MutableList<ViaPoint>): To set list of via points.lastRiderLocation(Point): This parameter is used to pass the last known location (long,lat) coordinates of the rider.
Method calls :-¶
-
For Start Tracking¶
Kotlin¶
~~~kotlin val startmarkerLocation = Point.fromLngLat( 77.26890561043258, 28.550947419414012 ) mapplsTrackingManager?.startTrackingVehicle(startmarkerLocation) ~~~
Java¶
~~~java Point startMarkerLocation = Point.fromLngLat(77.26890561043258, 28.550947419414012); if (mapplsTrackingManager != null) { mapplsTrackingManager.startTrackingVehicle(startMarkerLocation); } ~~~ - #### For Removing Curved Line
Kotlin¶
~~~kotlin mapplsTrackingManager?.removeCurveLine(true) ~~~
Java¶
~~~java if (mapplsTrackingManager != null) { mapplsTrackingManager.removeCurveLine(true); } ~~~ - #### For Hide/Show Polyline
Kotlin¶
~~~kotlin mapplsTrackingManager?.setPolylineVisibility(false) ~~~
Java¶
~~~java if (mapplsTrackingManager != null) { mapplsTrackingManager.setPolylineVisibility(false); } - #### For Enable/Disable FitBound Route
Kotlin¶
~~~kotlin mapplsTrackingManager?.setFitBounds(false, 15.0, Padding(0, 0, 0, 0)) ~~~
Java¶
~~~java if (mapplsTrackingManager != null) { mapplsTrackingManager.setFitBounds(false, 15.0, new Padding(0, 0, 0, 0)); } ~~~ - #### For removing vaiPoint based on Id
Kotlin¶
~~~kotlin mapplsTrackingManager?.removeViaPointById(
) { success -> if (success) { Toast.makeText(this,"Waypoint Successfully removed",Toast.LENGTH_LONG).show() } else { Toast.makeText(this, "Waypoint Failed to remove", Toast.LENGTH_LONG).show() } } ~~~ Java¶
~~~java mapplsTrackingManager.removeViaPointById("", new Function1
() { @Override public Unit invoke(Boolean success) { if (success) { Toast.makeText(this, "Waypoint Successfully removed", Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "Waypoint Failed to remove", Toast.LENGTH_LONG).show(); } return Unit.INSTANCE; // <- required } }); ~~~
For any queries and support, please contact:
Email us at apisupport@mappls.com
Support
Need support? contact us!
