diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 2651153..c7f7d96 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -389,12 +389,6 @@
-
-
();
- 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 locationsInfos;
-
- private double startLat = 39.90748811582486;
- private double startlng = 116.39768397709094;
- private double endLat = 39.95733416663634;
- private double endLng = 116.42347954147459;
-
- private List polylines = new ArrayList<>();
- private List 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 latLngs = new ArrayList<>();
- List 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();
- }
-}
diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/StartYunDanActivity.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/StartYunDanActivity.java
index 342e226..166148e 100644
--- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/StartYunDanActivity.java
+++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/home/StartYunDanActivity.java
@@ -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.SDKInitializer;
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.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;
@@ -70,7 +87,7 @@ public class StartYunDanActivity extends BaseActivity {
private String TAG = "StartYunDanActivity";
private NestedScrollView bottomSheet;
- private MapView map;
+ private MapView mapView;
private BaseRecyclerView brv;
private AlphaAnimation mShowAnim, mHiddenAmin;//控件的显示和隐藏动画
private LinearLayout protect;
@@ -139,6 +156,10 @@ public class StartYunDanActivity extends BaseActivity {
StateStyleUtil.stateTextColor(this);
setContentView(R.layout.activity_yundan_start);
con = this;
+ mapView = findViewById(R.id.map);
+ mapView.onCreate(savedInstanceState);
+ mLKMap = mapView.getMap();
+ initMap();
id = getIntent().getExtras().getInt("id");
brv = findViewById(R.id.brv);
protect = findViewById(R.id.protect);
@@ -148,11 +169,10 @@ public class StartYunDanActivity extends BaseActivity {
mBottomSheetBehavior.setHideable(false);
mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
//mBottomSheetBehavior.set
- map = findViewById(R.id.map);
- map.onCreate(savedInstanceState);
+
// initLoaction();
- initMap();
+
Log.e("--id--", "" + id);
String userdata = SPUtil.getSP(con, "data", "userdata");
if (!userdata.equals("")) {
@@ -302,6 +322,7 @@ public class StartYunDanActivity extends BaseActivity {
initZX(upkey, v15, position, o, 1);
});
// search();
+ doSearch();
}
public void initZX(boolean key, View v, int position, Object o, int type) {
@@ -435,8 +456,8 @@ public class StartYunDanActivity extends BaseActivity {
@Override
protected void onResume() {
super.onResume();
- if (map != null) {
- map.onResume();
+ if (mapView != null) {
+ mapView.onResume();
}
hyr.startOrder(id);
hyr.getEvaluate(id);
@@ -445,23 +466,23 @@ public class StartYunDanActivity extends BaseActivity {
@Override
protected void onPause() {
super.onPause();
- if (map != null) {
- map.onPause();
+ if (mapView != null) {
+ mapView.onPause();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
- if (map != null) {
- map.onDestroy();
+ if (mapView != null) {
+ mapView.onDestroy();
}
}
@Override
protected void onSaveInstanceState(@NonNull @NotNull Bundle outState) {
super.onSaveInstanceState(outState);
- map.onSaveInstanceState(outState);
+ mapView.onSaveInstanceState(outState);
}
LocationSource.OnLocationChangedListener mListener;
@@ -554,6 +575,124 @@ public class StartYunDanActivity extends BaseActivity {
SDKInitializer.initialization(getApplicationContext(),options);
}
+ private DrivingRoutePlanOptions drivingRoutePlanOptions;
+ private List locationsInfos;
+
+ private List polylines = new ArrayList<>();
+ private List 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 latLngs = new ArrayList<>();
+ List 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 List 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();
+ }
+
}
diff --git a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/my/MyFragment.java b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/my/MyFragment.java
index 3bdde26..4bcc71a 100644
--- a/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/my/MyFragment.java
+++ b/app/src/main/java/com/arpa/hndahesudintocctmsdriver/ui/my/MyFragment.java
@@ -17,7 +17,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import com.arpa.hndahesudintocctmsdriver.TextMapActivity;
import com.arpa.hndahesudintocctmsdriver.event.PersonEvent;
import com.arpa.hndahesudintocctmsdriver.event.RefreshCarListEvent;
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.UserParts;
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.google.gson.Gson;
import com.lxj.xpopup.XPopup;
@@ -237,28 +234,24 @@ public class MyFragment extends BaseFragment {
});
//联系我们
onContact.setOnClickListener(v -> {
-
- Intent in=new Intent(con, TextMapActivity.class);
- startActivity(in);
-
-// String serviceMobile = "";
-// if (ConfigParts.getConfigParts(con) != null) {
-// serviceMobile = ConfigParts.getConfigParts(con).getData().getServiceMobile();
-// serviceMobile = StringUtil.isNull(serviceMobile, "");
-// }
-// String[] title = {"平台客服:" + serviceMobile};
-// String[] value = {serviceMobile};
-// new XPopup.Builder(con)
-// .isDarkTheme(false)
-// .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
-// .asCenterList("请选择", title,
-// (position1, text) -> {
-// Intent intent = new Intent(Intent.ACTION_DIAL);
-// Uri data = Uri.parse("tel:" + value[position1]);
-// intent.setData(data);
-// startActivity(intent);
-// })
-// .show();
+ String serviceMobile = "";
+ if (ConfigParts.getConfigParts(con) != null) {
+ serviceMobile = ConfigParts.getConfigParts(con).getData().getServiceMobile();
+ serviceMobile = StringUtil.isNull(serviceMobile, "");
+ }
+ String[] title = {"平台客服:" + serviceMobile};
+ String[] value = {serviceMobile};
+ new XPopup.Builder(con)
+ .isDarkTheme(false)
+ .isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
+ .asCenterList("请选择", title,
+ (position1, text) -> {
+ Intent intent = new Intent(Intent.ACTION_DIAL);
+ Uri data = Uri.parse("tel:" + value[position1]);
+ intent.setData(data);
+ startActivity(intent);
+ })
+ .show();
});
//咨询建议
onOpinion.setOnClickListener(v -> {
diff --git a/app/src/main/res/layout/activity_base_map.xml b/app/src/main/res/layout/activity_base_map.xml
deleted file mode 100644
index 04576df..0000000
--- a/app/src/main/res/layout/activity_base_map.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file