From 8a9fc88104727c821832dfdaec4f66901c66bdb8 Mon Sep 17 00:00:00 2001 From: lizhanwei <Dana_Lee1016@126.com> Date: 星期四, 18 六月 2020 17:48:14 +0800 Subject: [PATCH] 车辆动态绘制,根据坐标点和角度 --- app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java b/app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java index 36866fd..454809f 100644 --- a/app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java +++ b/app/src/main/java/safeluck/drive/evaluation/fragment/JiaXiaoFragment.java @@ -3,6 +3,8 @@ import android.graphics.Color; import android.os.Bundle; +import android.os.Handler; +import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -53,6 +55,9 @@ import java.util.Iterator; import java.util.List; import java.util.ListIterator; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; import me.yokeyword.fragmentation.SupportFragment; import safeluck.drive.evaluation.R; @@ -75,12 +80,27 @@ private static final String TAG = JiaXiaoFragment.class.getSimpleName(); private MapView mMapView ; + private static final int MSG_CAR = 100; + double yaw = 0; GraphicsOverlay mGraphicsOverlay; + private int count =0; + private double startX = -8647.003,startY = 14590.7213; + private Handler mHandler = new Handler(){ + @Override + public void handleMessage(Message msg) { + switch (msg.what){ + case MSG_CAR: + count++; + yaw +=count; + addGraphicLayer(yaw,startX+count,startY+count); + sendEmptyMessageDelayed(MSG_CAR,1000); + break; + } + } + }; PointCollection mPointCollection = new PointCollection(SpatialReference.create(4544)); - - @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { @@ -91,7 +111,9 @@ setupMap(); addTrailheadsLayer(); // addImageLayer(); - addGraphicLayer(); + + mHandler.sendEmptyMessageDelayed(MSG_CAR,1000); + // drawPolygon(); return view; } @@ -128,11 +150,13 @@ } }); + + } - private void addGraphicLayer(){ + private void addGraphicLayer(double yaw,double x,double y){ SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, Color.rgb(232,0,0), 0.5f); SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, Color.argb(255,232,0,0), lineSymbol); @@ -144,7 +168,7 @@ Log.i(TAG,"giscar="+buffer.toString()); GisCarModel gisCarModel= new Gson().fromJson(buffer.toString(),GisCarModel.class); // List<safeluck.drive.evaluation.bean.Point> carNew=Utils.getCarPoint(0,45,new safeluck.drive.evaluation.bean.Point(-8633.77199999988,14471.793700000271)); - List<safeluck.drive.evaluation.bean.Point> carNew=Utils.getCarPoint(0,45,new safeluck.drive.evaluation.bean.Point(-8647.003,14590.7213)); + List<safeluck.drive.evaluation.bean.Point> carNew=Utils.getCarPoint(0,yaw,new safeluck.drive.evaluation.bean.Point(x,y)); List<Integer> bodys =gisCarModel.getBody(); for (int i = 0; i <bodys.size(); i++) { Log.i(TAG,String.format("杞﹁韩鐐逛綅缃細%d",bodys.get(i))); @@ -163,7 +187,7 @@ drawrightCenterGls(gisCarModel,carNew); - drawPoint(new Point(-8647.003,14590.7213)); + drawPoint(new Point(x,y)); } }); -- Gitblit v1.8.0