// Driver's current location private void HomeFragment_CurrentLocation(object sender, HomeFragment.OnLocationCapturedEventArgs e) { mLastLocation = e.Location; mLastLatLng = new LatLng(mLastLocation.Latitude, mLastLocation.Longitude); // check if driver is online to update his/her location if (availabilityListener != null) { availabilityListener.UpdateLocation(mLastLocation); } if (availabilityStatus && availabilityListener == null) { TakeDriverOnline(); } // picking patient if (status == "ACCEPTED") { // update and animate driver movement to location LatLng pickupLatLng = new LatLng(newRideDetails.PickupLat, newRideDetails.PickupLng); mapHelper.UpdateMovement(mLastLatLng, pickupLatLng, "Rider"); // Update location in rideRequest table so that rider can receive updates newTripEventListener.UpdateLocation(mLastLocation); } else if (status == "ARRIVED") { newTripEventListener.UpdateLocation(mLastLocation); } else if (status == "ONTRIP") { // Update and animate driver movement to destination LatLng destinationLatLng = new LatLng(newRideDetails.DestinationLat, newRideDetails.DestinationLng); mapHelper.UpdateMovement(mLastLatLng, destinationLatLng, "Destination"); // Update Location in ride request Table, so that rider receives updates newTripEventListener.UpdateLocation(mLastLocation); } }
private void LocationManager_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e) { CameraPosition cp = CameraPosition.FromCamera(e.Locations[0].Coordinate, 15); currentLocation = e.Locations[0].Coordinate; if (string.IsNullOrEmpty(status)) { googleMap.Animate(cp); } // Updates drivers current location as location changes while he waits for a request if (availabiltyListener != null) { if (avalability) { availabiltyListener.UpdateLocation(currentLocation); } } if (status == "ACCEPTED") { //Update and Animate driver movement to pick up location var pickupLatLng = new CLLocationCoordinate2D(newRideDetails.PickupLat, newRideDetails.PickLng); mapHelper.UpdateMovement(currentLocation, pickupLatLng, "Rider"); newtripListener.UpdateLocation(currentLocation); } else if (status == "ONTRIP") { var destinationLatLng = new CLLocationCoordinate2D(newRideDetails.DestinationLat, newRideDetails.DestinationLng); // Update and Animate driver movement to destination mapHelper.UpdateMovement(currentLocation, destinationLatLng, "destination"); //Update Location on Firebase newtripListener.UpdateLocation(currentLocation); } }