添加司机轨迹显示
This commit is contained in:
parent
ba1ba589a6
commit
0021ac1983
@ -100,6 +100,7 @@ public class OrderDetailsActivity extends BaseActivity {
|
|||||||
private boolean key = false;
|
private boolean key = false;
|
||||||
private int id = 0;
|
private int id = 0;
|
||||||
private ArrayList<LatLng> carPoints = new ArrayList<>();
|
private ArrayList<LatLng> carPoints = new ArrayList<>();
|
||||||
|
private ArrayList<LatLng> driverPoints = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void msgMethod(Message m) {
|
public void msgMethod(Message m) {
|
||||||
@ -169,6 +170,8 @@ public class OrderDetailsActivity extends BaseActivity {
|
|||||||
if (bb.getCode() == 200) {
|
if (bb.getCode() == 200) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
carPoints.clear();
|
carPoints.clear();
|
||||||
|
driverPoints.clear();
|
||||||
|
ArrayList<ArrayList<String>> pathDriver = bb.getData().getVo().get(0).getPath();
|
||||||
ArrayList<ArrayList<String>> path = bb.getData().getVo().get(1).getPath();
|
ArrayList<ArrayList<String>> path = bb.getData().getVo().get(1).getPath();
|
||||||
for (int i = 0; i < path.size(); i++) {
|
for (int i = 0; i < path.size(); i++) {
|
||||||
if (path.get(i).size() > 1) {
|
if (path.get(i).size() > 1) {
|
||||||
@ -184,6 +187,17 @@ public class OrderDetailsActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//司机轨迹
|
||||||
|
if (pathDriver.size() > 0) {
|
||||||
|
for (int i = 0; i < pathDriver.size(); i++) {
|
||||||
|
if (pathDriver.get(i).size() > 1) {
|
||||||
|
double lon = Double.parseDouble(pathDriver.get(i).get(0));
|
||||||
|
double lat = Double.parseDouble(pathDriver.get(i).get(1));
|
||||||
|
driverPoints.add(new LatLng(lat, lon));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
//绘制起始位置和目的地marker
|
//绘制起始位置和目的地marker
|
||||||
@ -192,17 +206,28 @@ public class OrderDetailsActivity extends BaseActivity {
|
|||||||
.position(new LatLng(Double.parseDouble(bb.getData().getStartLat()),
|
.position(new LatLng(Double.parseDouble(bb.getData().getStartLat()),
|
||||||
Double.parseDouble(bb.getData().getStartLon()))));
|
Double.parseDouble(bb.getData().getStartLon()))));
|
||||||
|
|
||||||
|
|
||||||
aMap.addMarker(new MarkerOptions()
|
aMap.addMarker(new MarkerOptions()
|
||||||
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.zhong))
|
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.zhong))
|
||||||
.position(new LatLng(Double.parseDouble(bb.getData().getEndLat()),
|
.position(new LatLng(Double.parseDouble(bb.getData().getEndLat()),
|
||||||
Double.parseDouble(bb.getData().getEndLon()))));
|
Double.parseDouble(bb.getData().getEndLon()))));
|
||||||
|
|
||||||
|
//添加车辆轨迹
|
||||||
aMap.addPolyline((new PolylineOptions())
|
aMap.addPolyline((new PolylineOptions())
|
||||||
.addAll(carPoints)
|
.addAll(carPoints)
|
||||||
//线的宽度
|
//线的宽度
|
||||||
.width(10)
|
.width(20f)
|
||||||
.color(getResources().getColor(R.color.teal_200)));
|
.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.icon_roud_type)));
|
||||||
|
|
||||||
|
|
||||||
|
if (driverPoints.size() > 0) {
|
||||||
|
//添加司机轨迹
|
||||||
|
aMap.addPolyline((new PolylineOptions())
|
||||||
|
.addAll(driverPoints)
|
||||||
|
//线的宽度
|
||||||
|
.width(20f)
|
||||||
|
.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.icon_roud_red)));
|
||||||
|
}
|
||||||
|
|
||||||
LatLngBounds.Builder builder = LatLngBounds.builder();
|
LatLngBounds.Builder builder = LatLngBounds.builder();
|
||||||
for (int i = 0; i < carPoints.size(); i++) {
|
for (int i = 0; i < carPoints.size(); i++) {
|
||||||
builder.include(carPoints.get(i));
|
builder.include(carPoints.get(i));
|
||||||
|
BIN
app/src/main/res/drawable-xxhdpi/icon_roud_red.jpg
Normal file
BIN
app/src/main/res/drawable-xxhdpi/icon_roud_red.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
app/src/main/res/drawable-xxhdpi/icon_roud_type.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/icon_roud_type.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
Loading…
Reference in New Issue
Block a user