箩筐地图路径规划
This commit is contained in:
parent
fce593a1b6
commit
400d4d18f1
@ -389,12 +389,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".TextMapActivity"
|
|
||||||
android:configChanges="keyboardHidden|orientation|locale"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:windowSoftInputMode="adjustPan|stateHidden"></activity>
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="com.arpa.hndahesudintocctmsdriver.push.XService"
|
android:name="com.arpa.hndahesudintocctmsdriver.push.XService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
@ -1,242 +0,0 @@
|
|||||||
package com.arpa.hndahesudintocctmsdriver;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.PersistableBundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import com.dahe.mylibrary.base.BaseActivity;
|
|
||||||
import com.lk.mapsdk.base.mapapi.model.LatLng;
|
|
||||||
import com.lk.mapsdk.base.mapapi.model.LatLngBounds;
|
|
||||||
import com.lk.mapsdk.map.mapapi.annotation.Marker;
|
|
||||||
import com.lk.mapsdk.map.mapapi.annotation.Polyline;
|
|
||||||
import com.lk.mapsdk.map.mapapi.annotation.options.MarkerOptions;
|
|
||||||
import com.lk.mapsdk.map.mapapi.annotation.options.PolylineOptions;
|
|
||||||
import com.lk.mapsdk.map.mapapi.annotation.util.BitmapDescriptorFactory;
|
|
||||||
import com.lk.mapsdk.map.mapapi.camera.MapStatusUpdateFactory;
|
|
||||||
import com.lk.mapsdk.map.mapapi.map.LKMap;
|
|
||||||
import com.lk.mapsdk.map.mapapi.map.MapView;
|
|
||||||
import com.lk.mapsdk.map.platform.style.layers.Property;
|
|
||||||
import com.lk.mapsdk.route.mapapi.base.AutoInfo;
|
|
||||||
import com.lk.mapsdk.route.mapapi.base.DrivingCostingOptionsInfo;
|
|
||||||
import com.lk.mapsdk.route.mapapi.base.LocationsInfo;
|
|
||||||
import com.lk.mapsdk.route.mapapi.driving.DrivingRoutePlan;
|
|
||||||
import com.lk.mapsdk.route.mapapi.driving.DrivingRoutePlanOptions;
|
|
||||||
import com.lk.mapsdk.route.mapapi.driving.DrivingRoutePlanResult;
|
|
||||||
import com.lk.mapsdk.route.mapapi.driving.OnDrivingRoutePlanListener;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName TextMapActivity
|
|
||||||
* @Author john
|
|
||||||
* @Date 2024/7/26 16:57
|
|
||||||
* @Description TODO
|
|
||||||
*/
|
|
||||||
public class TextMapActivity extends AppCompatActivity {
|
|
||||||
protected MapView mapView;
|
|
||||||
private LKMap mLKMap;
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_base_map);
|
|
||||||
mapView = findViewById(R.id.mapview);
|
|
||||||
mapView.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
mLKMap = mapView.getMap();
|
|
||||||
// LatLng center = new LatLng(39.916496, 116.421864);
|
|
||||||
// mLKMap.setMapStatus(MapStatusUpdateFactory.buildUpdateByCenterAndZoom(center, 8));
|
|
||||||
|
|
||||||
// doSearch();
|
|
||||||
doSearch2();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doSearch2(){
|
|
||||||
locationsInfos = new ArrayList<>();
|
|
||||||
drivingRoutePlanOptions = new DrivingRoutePlanOptions();
|
|
||||||
// 设置开始坐标
|
|
||||||
LocationsInfo origin = new LocationsInfo();
|
|
||||||
origin.setLat(39.90748811582486);
|
|
||||||
origin.setLon(116.39768397709094);
|
|
||||||
// 设置结束坐标
|
|
||||||
LocationsInfo dest = new LocationsInfo();
|
|
||||||
dest.setLat(39.95733416663634);
|
|
||||||
dest.setLon(116.42347954147459);
|
|
||||||
locationsInfos.add(origin);
|
|
||||||
locationsInfos.add(dest);
|
|
||||||
drivingRoutePlanOptions.setLocations(locationsInfos);
|
|
||||||
AutoInfo autoInfo = new AutoInfo();
|
|
||||||
DrivingCostingOptionsInfo drivingCostingOptionsInfo = new DrivingCostingOptionsInfo();
|
|
||||||
drivingCostingOptionsInfo.setAuto(autoInfo);
|
|
||||||
drivingRoutePlanOptions.setDrivingCostingOptions(drivingCostingOptionsInfo);
|
|
||||||
// 实例化路线规划结果监听器
|
|
||||||
DrivingRoutePlanListener searchListener = new DrivingRoutePlanListener();
|
|
||||||
|
|
||||||
DrivingRoutePlan routePlan = new DrivingRoutePlan();
|
|
||||||
|
|
||||||
// 发起路线规划
|
|
||||||
routePlan.drivingRoutePlanRequest(drivingRoutePlanOptions, searchListener);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DrivingRoutePlanListener implements OnDrivingRoutePlanListener {
|
|
||||||
@Override
|
|
||||||
public void onGetDrivingRoutePlanResult(DrivingRoutePlanResult routePlanResult) {
|
|
||||||
// 处理检索结果
|
|
||||||
addRoutePlanLine(routePlanResult);
|
|
||||||
addRouteMarker();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DrivingRoutePlanOptions drivingRoutePlanOptions;
|
|
||||||
private List<LocationsInfo> locationsInfos;
|
|
||||||
|
|
||||||
private double startLat = 39.90748811582486;
|
|
||||||
private double startlng = 116.39768397709094;
|
|
||||||
private double endLat = 39.95733416663634;
|
|
||||||
private double endLng = 116.42347954147459;
|
|
||||||
|
|
||||||
private List<Polyline> polylines = new ArrayList<>();
|
|
||||||
private List<Marker> markers = new ArrayList<>();
|
|
||||||
|
|
||||||
private void doSearch() {
|
|
||||||
DrivingRoutePlan search = new DrivingRoutePlan();
|
|
||||||
|
|
||||||
drivingRoutePlanOptions = new DrivingRoutePlanOptions();
|
|
||||||
locationsInfos = new ArrayList<>();
|
|
||||||
// 设置开始坐标
|
|
||||||
LocationsInfo origin = new LocationsInfo();
|
|
||||||
origin.setLat(startLat);
|
|
||||||
origin.setLon(startlng);
|
|
||||||
// 设置结束坐标
|
|
||||||
LocationsInfo dest = new LocationsInfo();
|
|
||||||
dest.setLat(endLat);
|
|
||||||
dest.setLon(endLng);
|
|
||||||
locationsInfos.add(origin);
|
|
||||||
locationsInfos.add(dest);
|
|
||||||
drivingRoutePlanOptions.setLocations(locationsInfos);
|
|
||||||
AutoInfo autoInfo = new AutoInfo();
|
|
||||||
DrivingCostingOptionsInfo drivingCostingOptionsInfo = new DrivingCostingOptionsInfo();
|
|
||||||
drivingCostingOptionsInfo.setAuto(autoInfo);
|
|
||||||
drivingRoutePlanOptions.setDrivingCostingOptions(drivingCostingOptionsInfo);
|
|
||||||
|
|
||||||
search.drivingRoutePlanRequest(drivingRoutePlanOptions, new OnDrivingRoutePlanListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGetDrivingRoutePlanResult(DrivingRoutePlanResult routePlanResult) {
|
|
||||||
addRoutePlanLine(routePlanResult);
|
|
||||||
addRouteMarker();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加线路规划路线
|
|
||||||
*
|
|
||||||
* @param routePlanResult
|
|
||||||
*/
|
|
||||||
private void addRoutePlanLine(DrivingRoutePlanResult routePlanResult) {
|
|
||||||
if (routePlanResult == null) {
|
|
||||||
Toast.makeText(this, "没有检索到结果", Toast.LENGTH_LONG).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (routePlanResult.getRouteInfos() == null || routePlanResult.getRouteInfos().isEmpty()) {
|
|
||||||
Toast.makeText(this, "没有检索到结果", Toast.LENGTH_LONG).show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<LatLng> latLngs = new ArrayList<>();
|
|
||||||
List<LatLng> all = new ArrayList<>();
|
|
||||||
mLKMap.removeOverlay(polylines);
|
|
||||||
polylines.clear();
|
|
||||||
for (int i = 0;i < routePlanResult.getRouteInfos().size();i ++){
|
|
||||||
latLngs.clear();
|
|
||||||
latLngs.addAll(routePlanResult.getRouteInfos().get(i).getGeometry());
|
|
||||||
PolylineOptions options = new PolylineOptions();
|
|
||||||
if(i == routePlanResult.getRouteInfos().size() - 1){
|
|
||||||
options.width(8f)
|
|
||||||
.pattern(BitmapDescriptorFactory.fromResource(R.drawable.icon_roud_type))
|
|
||||||
.joinStyle(Property.LINE_JOIN_ROUND)
|
|
||||||
.points(latLngs);
|
|
||||||
}else{
|
|
||||||
options.width(8f)
|
|
||||||
.pattern(BitmapDescriptorFactory.fromResource(R.drawable.icon_roud_type))
|
|
||||||
.joinStyle(Property.LINE_JOIN_ROUND)
|
|
||||||
.points(latLngs);
|
|
||||||
}
|
|
||||||
all.addAll(latLngs);
|
|
||||||
polylines.add((Polyline) mLKMap.addOverlay(options));
|
|
||||||
}
|
|
||||||
mLKMap.setMapStatus(MapStatusUpdateFactory.buildUpdateByLatLngBounds(new LatLngBounds(all),100,100,100,100));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加起始点标记
|
|
||||||
*/
|
|
||||||
private void addRouteMarker() {
|
|
||||||
mLKMap.removeOverlay(markers);
|
|
||||||
markers.clear();
|
|
||||||
MarkerOptions originOptions = new MarkerOptions()
|
|
||||||
.position(new LatLng(locationsInfos.get(0).getLat(),locationsInfos.get(0).getLon()))
|
|
||||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_loca_load))
|
|
||||||
.iconGravity(Property.ICON_ANCHOR_BOTTOM)
|
|
||||||
.iconScale(0.5f);
|
|
||||||
markers.add((Marker) mLKMap.addOverlay(originOptions));
|
|
||||||
|
|
||||||
MarkerOptions destinationOptions = new MarkerOptions()
|
|
||||||
.position(new LatLng(locationsInfos.get(1).getLat(),locationsInfos.get(1).getLon()))
|
|
||||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_loca_unload))
|
|
||||||
.iconGravity(Property.ICON_ANCHOR_BOTTOM)
|
|
||||||
.iconScale(0.5f);
|
|
||||||
markers.add((Marker) mLKMap.addOverlay(destinationOptions));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
mapView.onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
mapView.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
mapView.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
mapView.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSaveInstanceState(Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
mapView.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
mapView.onDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLowMemory() {
|
|
||||||
super.onLowMemory();
|
|
||||||
mapView.onDestroy();
|
|
||||||
}
|
|
||||||
}
|
|
@ -54,7 +54,24 @@ import com.arpa.hndahesudintocctmsdriver.util.view.ScoreView;
|
|||||||
import com.lk.mapsdk.base.mapapi.initializer.InitializerOptions;
|
import com.lk.mapsdk.base.mapapi.initializer.InitializerOptions;
|
||||||
import com.lk.mapsdk.base.mapapi.initializer.SDKInitializer;
|
import com.lk.mapsdk.base.mapapi.initializer.SDKInitializer;
|
||||||
import com.lk.mapsdk.base.mapapi.model.CoordType;
|
import com.lk.mapsdk.base.mapapi.model.CoordType;
|
||||||
|
import com.lk.mapsdk.base.mapapi.model.LatLng;
|
||||||
|
import com.lk.mapsdk.base.mapapi.model.LatLngBounds;
|
||||||
|
import com.lk.mapsdk.map.mapapi.annotation.Marker;
|
||||||
|
import com.lk.mapsdk.map.mapapi.annotation.Polyline;
|
||||||
|
import com.lk.mapsdk.map.mapapi.annotation.options.MarkerOptions;
|
||||||
|
import com.lk.mapsdk.map.mapapi.annotation.options.PolylineOptions;
|
||||||
|
import com.lk.mapsdk.map.mapapi.annotation.util.BitmapDescriptorFactory;
|
||||||
|
import com.lk.mapsdk.map.mapapi.camera.MapStatusUpdateFactory;
|
||||||
|
import com.lk.mapsdk.map.mapapi.map.LKMap;
|
||||||
import com.lk.mapsdk.map.mapapi.map.MapView;
|
import com.lk.mapsdk.map.mapapi.map.MapView;
|
||||||
|
import com.lk.mapsdk.map.platform.style.layers.Property;
|
||||||
|
import com.lk.mapsdk.route.mapapi.base.AutoInfo;
|
||||||
|
import com.lk.mapsdk.route.mapapi.base.DrivingCostingOptionsInfo;
|
||||||
|
import com.lk.mapsdk.route.mapapi.base.LocationsInfo;
|
||||||
|
import com.lk.mapsdk.route.mapapi.driving.DrivingRoutePlan;
|
||||||
|
import com.lk.mapsdk.route.mapapi.driving.DrivingRoutePlanOptions;
|
||||||
|
import com.lk.mapsdk.route.mapapi.driving.DrivingRoutePlanResult;
|
||||||
|
import com.lk.mapsdk.route.mapapi.driving.OnDrivingRoutePlanListener;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -70,7 +87,7 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
|
|
||||||
private String TAG = "StartYunDanActivity";
|
private String TAG = "StartYunDanActivity";
|
||||||
private NestedScrollView bottomSheet;
|
private NestedScrollView bottomSheet;
|
||||||
private MapView map;
|
private MapView mapView;
|
||||||
private BaseRecyclerView brv;
|
private BaseRecyclerView brv;
|
||||||
private AlphaAnimation mShowAnim, mHiddenAmin;//控件的显示和隐藏动画
|
private AlphaAnimation mShowAnim, mHiddenAmin;//控件的显示和隐藏动画
|
||||||
private LinearLayout protect;
|
private LinearLayout protect;
|
||||||
@ -139,6 +156,10 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
StateStyleUtil.stateTextColor(this);
|
StateStyleUtil.stateTextColor(this);
|
||||||
setContentView(R.layout.activity_yundan_start);
|
setContentView(R.layout.activity_yundan_start);
|
||||||
con = this;
|
con = this;
|
||||||
|
mapView = findViewById(R.id.map);
|
||||||
|
mapView.onCreate(savedInstanceState);
|
||||||
|
mLKMap = mapView.getMap();
|
||||||
|
initMap();
|
||||||
id = getIntent().getExtras().getInt("id");
|
id = getIntent().getExtras().getInt("id");
|
||||||
brv = findViewById(R.id.brv);
|
brv = findViewById(R.id.brv);
|
||||||
protect = findViewById(R.id.protect);
|
protect = findViewById(R.id.protect);
|
||||||
@ -148,11 +169,10 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
mBottomSheetBehavior.setHideable(false);
|
mBottomSheetBehavior.setHideable(false);
|
||||||
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
|
||||||
//mBottomSheetBehavior.set
|
//mBottomSheetBehavior.set
|
||||||
map = findViewById(R.id.map);
|
|
||||||
map.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
// initLoaction();
|
// initLoaction();
|
||||||
initMap();
|
|
||||||
Log.e("--id--", "" + id);
|
Log.e("--id--", "" + id);
|
||||||
String userdata = SPUtil.getSP(con, "data", "userdata");
|
String userdata = SPUtil.getSP(con, "data", "userdata");
|
||||||
if (!userdata.equals("")) {
|
if (!userdata.equals("")) {
|
||||||
@ -302,6 +322,7 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
initZX(upkey, v15, position, o, 1);
|
initZX(upkey, v15, position, o, 1);
|
||||||
});
|
});
|
||||||
// search();
|
// search();
|
||||||
|
doSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initZX(boolean key, View v, int position, Object o, int type) {
|
public void initZX(boolean key, View v, int position, Object o, int type) {
|
||||||
@ -435,8 +456,8 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (map != null) {
|
if (mapView != null) {
|
||||||
map.onResume();
|
mapView.onResume();
|
||||||
}
|
}
|
||||||
hyr.startOrder(id);
|
hyr.startOrder(id);
|
||||||
hyr.getEvaluate(id);
|
hyr.getEvaluate(id);
|
||||||
@ -445,23 +466,23 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if (map != null) {
|
if (mapView != null) {
|
||||||
map.onPause();
|
mapView.onPause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
if (map != null) {
|
if (mapView != null) {
|
||||||
map.onDestroy();
|
mapView.onDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSaveInstanceState(@NonNull @NotNull Bundle outState) {
|
protected void onSaveInstanceState(@NonNull @NotNull Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
map.onSaveInstanceState(outState);
|
mapView.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
|
||||||
LocationSource.OnLocationChangedListener mListener;
|
LocationSource.OnLocationChangedListener mListener;
|
||||||
@ -554,6 +575,124 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
SDKInitializer.initialization(getApplicationContext(),options);
|
SDKInitializer.initialization(getApplicationContext(),options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DrivingRoutePlanOptions drivingRoutePlanOptions;
|
||||||
|
private List<LocationsInfo> locationsInfos;
|
||||||
|
|
||||||
|
private List<Polyline> polylines = new ArrayList<>();
|
||||||
|
private List<Marker> markers = new ArrayList<>();
|
||||||
|
|
||||||
|
private LKMap mLKMap;
|
||||||
|
|
||||||
|
private void doSearch() {
|
||||||
|
DrivingRoutePlan search = new DrivingRoutePlan();
|
||||||
|
|
||||||
|
drivingRoutePlanOptions = new DrivingRoutePlanOptions();
|
||||||
|
locationsInfos = new ArrayList<>();
|
||||||
|
// 设置开始坐标
|
||||||
|
LocationsInfo origin = new LocationsInfo();
|
||||||
|
origin.setLat(Double.parseDouble(sob.getData().getWayChildren().get(0).getLatitude()));
|
||||||
|
origin.setLon(Double.parseDouble(sob.getData().getWayChildren().get((0)).getLongitude()));
|
||||||
|
// 设置结束坐标
|
||||||
|
LocationsInfo dest = new LocationsInfo();
|
||||||
|
dest.setLat(Double.parseDouble(sob.getData().getWayChildren().get((sob.getData().getWayChildren().size() - 1)).getLatitude()));
|
||||||
|
dest.setLon(Double.parseDouble(sob.getData().getWayChildren().get((sob.getData().getWayChildren().size() - 1)).getLongitude()));
|
||||||
|
locationsInfos.add(origin);
|
||||||
|
locationsInfos.add(dest);
|
||||||
|
drivingRoutePlanOptions.setLocations(locationsInfos);
|
||||||
|
AutoInfo autoInfo = new AutoInfo();
|
||||||
|
DrivingCostingOptionsInfo drivingCostingOptionsInfo = new DrivingCostingOptionsInfo();
|
||||||
|
drivingCostingOptionsInfo.setAuto(autoInfo);
|
||||||
|
drivingRoutePlanOptions.setDrivingCostingOptions(drivingCostingOptionsInfo);
|
||||||
|
|
||||||
|
search.drivingRoutePlanRequest(drivingRoutePlanOptions, new OnDrivingRoutePlanListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGetDrivingRoutePlanResult(DrivingRoutePlanResult routePlanResult) {
|
||||||
|
addRoutePlanLine(routePlanResult);
|
||||||
|
addRouteMarker();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加线路规划路线
|
||||||
|
*
|
||||||
|
* @param routePlanResult
|
||||||
|
*/
|
||||||
|
private void addRoutePlanLine(DrivingRoutePlanResult routePlanResult) {
|
||||||
|
if (routePlanResult == null) {
|
||||||
|
Toast.makeText(this, "没有检索到结果", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (routePlanResult.getRouteInfos() == null || routePlanResult.getRouteInfos().isEmpty()) {
|
||||||
|
Toast.makeText(this, "没有检索到结果", Toast.LENGTH_LONG).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<LatLng> latLngs = new ArrayList<>();
|
||||||
|
List<LatLng> all = new ArrayList<>();
|
||||||
|
mLKMap.removeOverlay(polylines);
|
||||||
|
polylines.clear();
|
||||||
|
|
||||||
|
if (routePlanResult.getRouteInfos().size()>0){
|
||||||
|
latLngs.clear();
|
||||||
|
latLngs.addAll(routePlanResult.getRouteInfos().get(0).getGeometry());
|
||||||
|
PolylineOptions options = new PolylineOptions();
|
||||||
|
options.width(8f)
|
||||||
|
.joinStyle(Property.LINE_JOIN_ROUND)
|
||||||
|
.points(latLngs)
|
||||||
|
.color(getResources().getColor(R.color.theme_color));
|
||||||
|
all.addAll(latLngs);
|
||||||
|
polylines.add((Polyline) mLKMap.addOverlay(options));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// for (int i = 0;i < routePlanResult.getRouteInfos().size();i ++){
|
||||||
|
// latLngs.clear();
|
||||||
|
// latLngs.addAll(routePlanResult.getRouteInfos().get(i).getGeometry());
|
||||||
|
// PolylineOptions options = new PolylineOptions();
|
||||||
|
// if(i == routePlanResult.getRouteInfos().size() - 1){
|
||||||
|
// options.width(8f)
|
||||||
|
//// .pattern(BitmapDescriptorFactory.fromResource(R.drawable.icon_roud_type))
|
||||||
|
// .joinStyle(Property.LINE_JOIN_ROUND)
|
||||||
|
// .points(latLngs)
|
||||||
|
// .color(getResources().getColor(R.color.theme_color));
|
||||||
|
// }else{
|
||||||
|
// options.width(8f)
|
||||||
|
//// .joinStyle(Property.LINE_JOIN_ROUND)
|
||||||
|
// .points(latLngs)
|
||||||
|
// .color(getResources().getColor(R.color.theme_color));
|
||||||
|
// }
|
||||||
|
// all.addAll(latLngs);
|
||||||
|
// polylines.add((Polyline) mLKMap.addOverlay(options));
|
||||||
|
// }
|
||||||
|
mLKMap.setMapStatus(MapStatusUpdateFactory.buildUpdateByLatLngBounds(new LatLngBounds(all),100,100,100,100));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加起始点标记
|
||||||
|
*/
|
||||||
|
private void addRouteMarker() {
|
||||||
|
mLKMap.removeOverlay(markers);
|
||||||
|
markers.clear();
|
||||||
|
MarkerOptions originOptions = new MarkerOptions()
|
||||||
|
.position(new LatLng(locationsInfos.get(0).getLat(),locationsInfos.get(0).getLon()))
|
||||||
|
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.qi))
|
||||||
|
.iconGravity(Property.ICON_ANCHOR_BOTTOM)
|
||||||
|
.iconScale(0.5f);
|
||||||
|
markers.add((Marker) mLKMap.addOverlay(originOptions));
|
||||||
|
|
||||||
|
MarkerOptions destinationOptions = new MarkerOptions()
|
||||||
|
.position(new LatLng(locationsInfos.get(1).getLat(),locationsInfos.get(1).getLon()))
|
||||||
|
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.zhong))
|
||||||
|
.iconGravity(Property.ICON_ANCHOR_BOTTOM)
|
||||||
|
.iconScale(0.5f);
|
||||||
|
markers.add((Marker) mLKMap.addOverlay(destinationOptions));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// private RouteSearch mRouteSearch;//路线查询器
|
// private RouteSearch mRouteSearch;//路线查询器
|
||||||
// private List<LatLonPoint> lists = new ArrayList<>();
|
// private List<LatLonPoint> lists = new ArrayList<>();
|
||||||
@ -694,4 +833,25 @@ public class StartYunDanActivity extends BaseActivity {
|
|||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
super.onStart();
|
||||||
|
mapView.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
mapView.onStop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLowMemory() {
|
||||||
|
super.onLowMemory();
|
||||||
|
mapView.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.arpa.hndahesudintocctmsdriver.TextMapActivity;
|
|
||||||
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
|
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
|
||||||
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
|
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
|
||||||
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
import com.arpa.hndahesudintocctmsdriver.event.VehicleEvent;
|
||||||
@ -25,8 +24,6 @@ import com.arpa.hndahesudintocctmsdriver.parts.ConfigParts;
|
|||||||
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
import com.arpa.hndahesudintocctmsdriver.parts.StartOrderParts;
|
||||||
import com.arpa.hndahesudintocctmsdriver.parts.UserParts;
|
import com.arpa.hndahesudintocctmsdriver.parts.UserParts;
|
||||||
import com.arpa.hndahesudintocctmsdriver.ui.business.BusinessActivity;
|
import com.arpa.hndahesudintocctmsdriver.ui.business.BusinessActivity;
|
||||||
import com.arpa.hndahesudintocctmsdriver.ui.home.StartYunDanActivity;
|
|
||||||
import com.arpa.hndahesudintocctmsdriver.util.PicturlUtil;
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
@ -237,28 +234,24 @@ public class MyFragment extends BaseFragment {
|
|||||||
});
|
});
|
||||||
//联系我们
|
//联系我们
|
||||||
onContact.setOnClickListener(v -> {
|
onContact.setOnClickListener(v -> {
|
||||||
|
String serviceMobile = "";
|
||||||
Intent in=new Intent(con, TextMapActivity.class);
|
if (ConfigParts.getConfigParts(con) != null) {
|
||||||
startActivity(in);
|
serviceMobile = ConfigParts.getConfigParts(con).getData().getServiceMobile();
|
||||||
|
serviceMobile = StringUtil.isNull(serviceMobile, "");
|
||||||
// String serviceMobile = "";
|
}
|
||||||
// if (ConfigParts.getConfigParts(con) != null) {
|
String[] title = {"平台客服:" + serviceMobile};
|
||||||
// serviceMobile = ConfigParts.getConfigParts(con).getData().getServiceMobile();
|
String[] value = {serviceMobile};
|
||||||
// serviceMobile = StringUtil.isNull(serviceMobile, "");
|
new XPopup.Builder(con)
|
||||||
// }
|
.isDarkTheme(false)
|
||||||
// String[] title = {"平台客服:" + serviceMobile};
|
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
||||||
// String[] value = {serviceMobile};
|
.asCenterList("请选择", title,
|
||||||
// new XPopup.Builder(con)
|
(position1, text) -> {
|
||||||
// .isDarkTheme(false)
|
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||||
// .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
Uri data = Uri.parse("tel:" + value[position1]);
|
||||||
// .asCenterList("请选择", title,
|
intent.setData(data);
|
||||||
// (position1, text) -> {
|
startActivity(intent);
|
||||||
// Intent intent = new Intent(Intent.ACTION_DIAL);
|
})
|
||||||
// Uri data = Uri.parse("tel:" + value[position1]);
|
.show();
|
||||||
// intent.setData(data);
|
|
||||||
// startActivity(intent);
|
|
||||||
// })
|
|
||||||
// .show();
|
|
||||||
});
|
});
|
||||||
//咨询建议
|
//咨询建议
|
||||||
onOpinion.setOnClickListener(v -> {
|
onOpinion.setOnClickListener(v -> {
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.lk.mapsdk.map.mapapi.map.MapView
|
|
||||||
android:id="@+id/mapview"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
app:lk_cameraTargetLat="39.914271"
|
|
||||||
app:lk_cameraTargetLng="116.467797"
|
|
||||||
app:lk_cameraZoom="8"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
Loading…
Reference in New Issue
Block a user