@Override protected Void doInBackground(Void... params) { oConfigTrainer = ExerciseUtils.loadConfiguration(mContext); ExerciseUtils.populateExerciseDetails(mContext, oConfigTrainer, mIDWorkout); aLatLng = new ArrayList<LatLng>(); for (int i = 0; i < ExerciseManipulate.getWatchPoint().size(); i++) { aLatLng.add(ExerciseManipulate.getWatchPoint().get(i).getLatLong()); } while (oMapView == null) { try { Thread.sleep(1000); } catch (InterruptedException e) { Log.e(this.getClass().getCanonicalName(), "Error during wait maps"); } } return null; }
@Override protected void onPostExecute(Void result) { Polyline route = oMapView.addPolyline(new PolylineOptions().width(5).color(Color.BLUE).geodesic(true)); route.setPoints(aLatLng); oMapView.addMarker( new MarkerOptions() .position(ExerciseManipulate.getWatchPoint().get(0).getLatLong()) .title("Start")); oMapView.addMarker( new MarkerOptions() .position( ExerciseManipulate.getWatchPoint() .get(ExerciseManipulate.getWatchPoint().size() - 1) .getLatLong()) .title("End " + ExerciseManipulate.getsTotalDistance())); CameraPosition newCamPos = new CameraPosition( ExerciseManipulate.getWatchPoint() .get(ExerciseManipulate.getWatchPoint().size() / 2) .getLatLong(), 12.5f, oMapView.getCameraPosition().tilt, // use old tilt oMapView.getCameraPosition().bearing); // use old bearing oMapView.animateCamera(CameraUpdateFactory.newCameraPosition(newCamPos), 4000, null); // oMapView.addPolyline((new PolylineOptions()).addAll(aLatLng)); // oMapView.moveCamera(CameraUpdateFactory.newLatLng(ExerciseManipulate.getWatchPoint().get(0).getLatLong())); }