, API- Android Mapbox.
1. , , , /?
-, , .setSteps(true) MapboxDirections.Builder(). . , , , . , , , . , (, 0,0189394 , ~ 100 ), . , , :
private double computeDistance(Waypoint from, Waypoint to) {
double dLat = Math.toRadians(to.getLatitude() - from.getLatitude());
double dLon = Math.toRadians(to.getLongitude() - from.getLongitude());
double lat1 = Math.toRadians(from.getLatitude());
double lat2 = Math.toRadians(to.getLatitude());
double a = Math.pow(Math.sin(dLat/2), 2) + Math.pow(Math.sin(dLon/2), 2) * Math.cos(lat1) * Math.cos(lat2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
double R = 3960;
double distance = R * c;
return distance;
}
, ( ) ( 0,0189394 ), , .
2. , /? , ?
1. , mapView.setOnMyLocationChangeListener MapView.OnMyLocationChangeListener(). , 1.
3. , ? , , . .
, isOffRoute(), userLocation , , ( 0,2 ). , , , if, :
if (route.isOffRoute(userLocation)) {
Toast.makeText(this, "You are off-route.", Toast.LENGTH_SHORT).show();
}
, , . , , 1.1, . ββ.
, , .