@Override public void trackFinish(@NonNull Track track) { List<Location> trackList = track.getTracks(); JSONObject object = new JSONObject(); try { object.put("userID", facebookId); object.put("func", "addTrack"); object.put("date", Calendar.getInstance().getTimeInMillis() + ""); JSONArray array = new JSONArray(); for (Location g : trackList) { JSONObject o = new JSONObject(); o.put("lat", "" + g.getLocation().getLatitude()); o.put("lon", "" + g.getLocation().getLongitude()); o.put("date", g.getDate().toString()); // o.put("alt", g.getAltitude() + ""); // o.put("speed", g.getSpeed() + ""); // o.put("slant", g.getSlant() + ""); array.put(o); } object.put("track", array); } catch (JSONException e) { e.printStackTrace(); } new HttpsAsyncTaskPosition().execute(SERVER_URL, "json=" + object.toString(), "sendTrack"); }
@Override protected void draw(Canvas canvas, MapView mapView, boolean shadow) { if (shadow) { return; } Paint textPaint = new Paint(); textPaint.setColor(Color.RED); textPaint.setStrokeWidth(5); Paint paint = new Paint(); paint.setStrokeWidth(20); paint.setColor(Color.RED); for (Location location : track.getTracks()) { Point out = new Point(); out = mapView.getProjection().toPixels(new GeoPoint(location.getLocation()), out); Bitmap b = BitmapFactory.decodeResource( this.context.getResources(), org.osmdroid.library.R.drawable.marker_default); canvas.drawBitmap(b, out.x - b.getWidth() / 2, out.y - b.getHeight(), paint); canvas.drawText(location.getDate().toString(), out.x, out.y + 22, textPaint); } }