This commit is contained in:
2026-04-14 11:50:33 +08:00
parent 881da166d1
commit f01875abb9
4 changed files with 169 additions and 126 deletions

View File

@@ -76,6 +76,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatButton;
import io.flutter.plugin.platform.PlatformView; import io.flutter.plugin.platform.PlatformView;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
@@ -204,6 +205,8 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
endInput = new TextView(context); endInput = new TextView(context);
endInput.setHint("请输入目的地,不输入则自动匹配推荐加氢站"); endInput.setHint("请输入目的地,不输入则自动匹配推荐加氢站");
endInput.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_search, 0, 0, 0);
endInput.setCompoundDrawablePadding(dp2px(8));
endInput.setTextSize(13); endInput.setTextSize(13);
endInput.setTextColor(Color.parseColor("#333333")); endInput.setTextColor(Color.parseColor("#333333"));
endInput.setHintTextColor(Color.GRAY); endInput.setHintTextColor(Color.GRAY);
@@ -248,8 +251,12 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
View vSpace = new View(context); View vSpace = new View(context);
searchArea.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(12))); searchArea.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(12)));
Button planBtn = new Button(context); AppCompatButton planBtn = new AppCompatButton(context);
planBtn.setText("规划路线"); planBtn.setText("规划路线");
planBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_path, 0, 0, 0);
planBtn.setCompoundDrawablePadding(dp2px(4));
planBtn.setGravity(Gravity.CENTER);
planBtn.setPadding(dp2px(8), 0, dp2px(8), 0);
planBtn.setTextColor(Color.WHITE); planBtn.setTextColor(Color.WHITE);
planBtn.setTypeface(Typeface.DEFAULT_BOLD); planBtn.setTypeface(Typeface.DEFAULT_BOLD);
planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 99)); planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 99));
@@ -377,8 +384,8 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
row1.setOrientation(LinearLayout.HORIZONTAL); row1.setOrientation(LinearLayout.HORIZONTAL);
row1.setGravity(Gravity.CENTER_VERTICAL); row1.setGravity(Gravity.CENTER_VERTICAL);
row1.setPadding(0, dp2px(8), 0, 0); // 增加行间距 row1.setPadding(0, dp2px(8), 0, 0); // 增加行间距
tvDuration = createInfoItem(row1, R.drawable.ic_time, "预计时间:", "", 1.0f); tvDuration = createInfoItem(row1, R.drawable.ic_time, "预计时间:", "-", 1.0f);
tvTollsFuel = createInfoItem(row1, R.drawable.ic_fuel, "加氢费用:", "", 1.0f); tvTollsFuel = createInfoItem(row1, R.drawable.ic_fuel, "加氢费用:", "-", 1.0f);
routeInfoLayout.addView(row1); routeInfoLayout.addView(row1);
// 第二行:里程 + 过路费 // 第二行:里程 + 过路费
@@ -388,9 +395,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
row2.setPadding(0, dp2px(10), 0, 0); // 增加行间距 row2.setPadding(0, dp2px(10), 0, 0); // 增加行间距
// 里程 // 里程
tvDistance = createInfoItem(row2, R.drawable.ic_mileage, "行驶里程:", "", 1.0f); tvDistance = createInfoItem(row2, R.drawable.ic_mileage, "行驶里程:", "-", 1.0f);
// 过路费 // 过路费
tvTolls = createInfoItem(row2, R.drawable.ic_toll, "过路费:", "", 1.0f); tvTolls = createInfoItem(row2, R.drawable.ic_toll, "过路费:", "-", 1.0f);
routeInfoLayout.addView(row2); routeInfoLayout.addView(row2);
//第三行 //第三行
@@ -398,15 +405,15 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
row3.setOrientation(LinearLayout.HORIZONTAL); row3.setOrientation(LinearLayout.HORIZONTAL);
row3.setGravity(Gravity.CENTER_VERTICAL); row3.setGravity(Gravity.CENTER_VERTICAL);
row3.setPadding(0, dp2px(8), 0, 0); // 增加行间距 row3.setPadding(0, dp2px(8), 0, 0); // 增加行间距
tvPerson = createInfoItem(row3, R.drawable.ic_person, "站联系人:", "", 1.0f); tvPerson = createInfoItem(row3, R.drawable.ic_person, "站联系人:", "-", 1.0f);
tvPrice = createInfoItem(row3, R.drawable.ic_price, "加氢价格:", "", 1.0f); tvPrice = createInfoItem(row3, R.drawable.ic_price, "加氢价格:", "-", 1.0f);
routeInfoLayout.addView(row3); routeInfoLayout.addView(row3);
LinearLayout row4 = new LinearLayout(context); LinearLayout row4 = new LinearLayout(context);
row4.setOrientation(LinearLayout.HORIZONTAL); row4.setOrientation(LinearLayout.HORIZONTAL);
row4.setGravity(Gravity.CENTER_VERTICAL); row4.setGravity(Gravity.CENTER_VERTICAL);
row4.setPadding(0, dp2px(8), 0, 0); // 增加行间距 row4.setPadding(0, dp2px(8), 0, 0); // 增加行间距
tvPhone = createInfoItem(row4, R.drawable.ic_phone, "联系方式:", "", 1.0f); tvPhone = createInfoItem(row4, R.drawable.ic_phone, "联系方式:", "-", 1.0f);
routeInfoLayout.addView(row4); routeInfoLayout.addView(row4);
@@ -431,6 +438,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
searchArea.setVisibility(View.VISIBLE); searchArea.setVisibility(View.VISIBLE);
planToggleBtn.setVisibility(View.VISIBLE); planToggleBtn.setVisibility(View.VISIBLE);
mLocBtn.setVisibility(View.VISIBLE); mLocBtn.setVisibility(View.VISIBLE);
} }
private boolean isGetInputtips = false; private boolean isGetInputtips = false;
@@ -449,6 +457,8 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
//如果是输入地址提示内容 //如果是输入地址提示内容
if (isGetInputtips) { if (isGetInputtips) {
truckRouteData = null;
RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(new LatLonPoint(startPoint.latitude, startPoint.longitude), new LatLonPoint(endPoint.latitude, endPoint.longitude)); RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(new LatLonPoint(startPoint.latitude, startPoint.longitude), new LatLonPoint(endPoint.latitude, endPoint.longitude));
RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DRIVING_SINGLE_DEFAULT, null, null, ""); RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DRIVING_SINGLE_DEFAULT, null, null, "");
routeSearch.calculateDriveRouteAsyn(query); routeSearch.calculateDriveRouteAsyn(query);
@@ -478,6 +488,11 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
String liaisonPhone = "-"; String liaisonPhone = "-";
String startBusiness = "-"; String startBusiness = "-";
String endBusiness = "-"; String endBusiness = "-";
double distanceKm = 0;
String distanceKmStr = "-";
long durationMin = 0;
String durationMinStr = "-";
String tolls = "-";
if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && !result.getPaths().isEmpty()) { if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && !result.getPaths().isEmpty()) {
@@ -494,17 +509,19 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
tvStationName.setText(endName); tvStationName.setText(endName);
tvStationAddr.setText(endAddress); tvStationAddr.setText(endAddress);
DestinationSite destinationSite = truckRouteData.destinationSite;
if (truckRouteData != null) {
PathDto pathDto = truckRouteData.pathDto; PathDto pathDto = truckRouteData.pathDto;
double distanceKm = 0;
long durationMin = 0;
String tolls = "-";
if (pathDto != null) { if (pathDto != null) {
distanceKm = pathDto.distance / 1000f; distanceKm = pathDto.distance / 1000f;
durationMin = pathDto.duration / 60; durationMin = pathDto.duration / 60;
tolls = pathDto.tolls + ""; tolls = pathDto.tolls + "";
distanceKmStr = String.format("%.1f", distanceKm) + "公里";
durationMinStr = durationMin + "分钟";
} }
}
// 增加多级非空校验,防止点击搜索条目时崩溃 // 增加多级非空校验,防止点击搜索条目时崩溃
if (truckRouteData != null && if (truckRouteData != null &&
@@ -515,26 +532,31 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
hydrogenCost = (isGetInputtips ? "--" : hydrogenCost) + ""; hydrogenCost = (isGetInputtips ? "--" : hydrogenCost) + "";
} }
tvDuration.setText("预计时间:" + durationMin + "分钟"); tvDuration.setText("预计时间:" + durationMinStr);
tvDistance.setText("行驶里程:" + String.format("%.1f", distanceKm) + "公里"); tvDistance.setText("行驶里程:" + distanceKmStr);
tvTolls.setText("过路费:" + tolls); tvTolls.setText("过路费:" + tolls);
tvTollsFuel.setText("预计加氢费用:" + hydrogenCost); tvTollsFuel.setText("预计加氢费用:" + hydrogenCost);
if (truckRouteData != null) {
DestinationSite destinationSite = truckRouteData.destinationSite;
if (destinationSite != null) { if (destinationSite != null) {
startBusiness = destinationSite.startBusiness; startBusiness = destinationSite.startBusiness;
endBusiness = destinationSite.endBusiness; endBusiness = destinationSite.endBusiness;
hydrogenPrice = destinationSite.hydrogenPrice; hydrogenPrice = destinationSite.hydrogenPrice + "/L";
liaisonName = destinationSite.liaisonName; liaisonName = destinationSite.liaisonName;
liaisonPhone = destinationSite.liaisonPhone; liaisonPhone = destinationSite.liaisonPhone;
//开始结束时间
startBusiness = startBusiness + "-" + endBusiness;
}
} }
tvBusinessHours.setText("营业时间:" + startBusiness + "-" + endBusiness); tvBusinessHours.setText("营业时间:" + startBusiness);
String displayValue = "";
if (liaisonName != null && liaisonName.length() > 5) { if (liaisonName != null && liaisonName.length() > 5) {
displayValue = liaisonName.substring(0, 5) + "..."; liaisonName = liaisonName.substring(0, 5) + "...";
} }
tvPerson.setText("站联系人:" + displayValue); tvPerson.setText("站联系人:" + liaisonName);
tvPrice.setText("加氢价格:" + hydrogenPrice + "/L"); tvPrice.setText("加氢价格:" + hydrogenPrice);
tvPhone.setText("联系方式:" + liaisonPhone); tvPhone.setText("联系方式:" + liaisonPhone);
isGetInputtips = false; isGetInputtips = false;
@@ -634,6 +656,11 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
// 检查途径点数量,决定使用哪种导航方式 // 检查途径点数量,决定使用哪种导航方式
int wayPointsCount = waysPoiIds.size(); int wayPointsCount = waysPoiIds.size();
Log.d(TAG, "途经点数量: " + wayPointsCount); Log.d(TAG, "途经点数量: " + wayPointsCount);
//如果是输入地址提示内容,不判断途经点
if (isGetInputtips) {
wayPointsCount = 0;
}
if (wayPointsCount > 3) { if (wayPointsCount > 3) {
// 途经点超过3个跳转到 NavigationActivity // 途经点超过3个跳转到 NavigationActivity
Intent intent = new Intent(mContext, NavigationActivity.class); Intent intent = new Intent(mContext, NavigationActivity.class);
@@ -826,11 +853,13 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
if (detailPanel != null && detailPanel.getVisibility() == View.VISIBLE) { if (detailPanel != null && detailPanel.getVisibility() == View.VISIBLE) {
resetView(); resetView();
} }
modeMenu.setVisibility(View.GONE);
}); });
aMap.setOnPOIClickListener(poi -> { aMap.setOnPOIClickListener(poi -> {
if (detailPanel != null && detailPanel.getVisibility() == View.VISIBLE) { if (detailPanel != null && detailPanel.getVisibility() == View.VISIBLE) {
resetView(); resetView();
} }
modeMenu.setVisibility(View.GONE);
}); });
MyLocationStyle myLocationStyle = new MyLocationStyle(); MyLocationStyle myLocationStyle = new MyLocationStyle();
@@ -1259,7 +1288,6 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
TextView tv = new TextView(mContext); TextView tv = new TextView(mContext);
tv.setText(label + value); tv.setText(label + value);
tv.setTextSize(12); tv.setTextSize(12);
@@ -1298,9 +1326,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
TextView item3 = createMenuItem(context, "加氢规划模式", true); TextView item3 = createMenuItem(context, "加氢规划模式", true);
item3.setOnClickListener(v -> switchMode("加氢规划")); item3.setOnClickListener(v -> switchMode("加氢规划"));
menu.addView(item1);
menu.addView(item2);
menu.addView(item3); menu.addView(item3);
menu.addView(item2);
menu.addView(item1);
return menu; return menu;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 596 B

View File

@@ -77,7 +77,6 @@
self.inputAddressTf = inputAddressTf; self.inputAddressTf = inputAddressTf;
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setTitle:@"当前位置" forState:UIControlStateNormal]; [btn setTitle:@"当前位置" forState:UIControlStateNormal];
btn.backgroundColor = [UIColor whiteColor]; btn.backgroundColor = [UIColor whiteColor];
@@ -112,7 +111,16 @@
} }
#pragma mark - #pragma mark -
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
- (nonnull UITableViewCell
*)tableView:(
nonnull UITableView
*)
tableView cellForRowAtIndexPath
:(
nonnull NSIndexPath
*)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) { if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"]; cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
@@ -125,7 +133,11 @@
return cell; return cell;
} }
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(nonnull UITableView
*)
tableView numberOfRowsInSection
:(NSInteger)section {
return self.dataArr.count; return self.dataArr.count;
} }
@@ -149,6 +161,7 @@
} }
#pragma mark - #pragma mark -
- (UITableView *)tableView { - (UITableView *)tableView {
if (!_tableView) { if (!_tableView) {
_tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
@@ -180,6 +193,7 @@
} }
#pragma mark - Action #pragma mark - Action
- (void)searchBtnAction { - (void)searchBtnAction {
AMapNavSDKManager *sdk = [AMapNavSDKManager sharedManager]; AMapNavSDKManager *sdk = [AMapNavSDKManager sharedManager];
self.inputAddressTf.text = sdk.locationAddressDetail; self.inputAddressTf.text = sdk.locationAddressDetail;
@@ -206,7 +220,7 @@
request.page = 1; request.page = 1;
/* SDK 3.2.0 POI*/ /* SDK 3.2.0 POI*/
request.cityLimit = YES; // request.cityLimit = YES;
// request.requireSubPOIs = YES; // request.requireSubPOIs = YES;
@@ -237,12 +251,11 @@
} }
#pragma mark - #pragma mark -
/* POI . */ /* POI . */
- (void)onPOISearchDone:(AMapPOISearchBaseRequest *)request response:(AMapPOISearchResponse *)response - (void)onPOISearchDone:(AMapPOISearchBaseRequest *)request response:(AMapPOISearchResponse *)response {
{
NSArray *pois = response.pois; NSArray *pois = response.pois;
if (pois.count == 0) if (pois.count == 0) {
{
return; return;
} }
@@ -255,7 +268,6 @@
} }
- (BOOL)textFieldShouldReturn:(UITextField *)textField { - (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder]; [textField resignFirstResponder];
[self.dataArr removeAllObjects]; [self.dataArr removeAllObjects];
@@ -267,8 +279,11 @@
} }
- (void)touchesBegan:(NSSet
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { <UITouch *> *)
touches withEvent
:(UIEvent *)event {
[self.inputAddressTf resignFirstResponder]; [self.inputAddressTf resignFirstResponder];
} }
@end @end