fix
This commit is contained in:
@@ -76,7 +76,6 @@ 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;
|
||||||
@@ -251,17 +250,33 @@ 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)));
|
||||||
|
|
||||||
AppCompatButton planBtn = new AppCompatButton(context);
|
// 创建自定义按钮布局
|
||||||
planBtn.setText("规划路线");
|
LinearLayout planBtnContainer = new LinearLayout(context);
|
||||||
planBtn.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_path, 0, 0, 0);
|
planBtnContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
planBtn.setCompoundDrawablePadding(dp2px(4));
|
planBtnContainer.setGravity(Gravity.CENTER);
|
||||||
planBtn.setGravity(Gravity.CENTER);
|
planBtnContainer.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 99));
|
||||||
planBtn.setPadding(dp2px(8), 0, dp2px(8), 0);
|
planBtnContainer.setPadding(0, 0, 0, 0);
|
||||||
planBtn.setTextColor(Color.WHITE);
|
|
||||||
planBtn.setTypeface(Typeface.DEFAULT_BOLD);
|
// 添加图标
|
||||||
planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 99));
|
ImageView pathIcon = new ImageView(context);
|
||||||
planBtn.setOnClickListener(v -> calculateRouteBeforeNavi());
|
pathIcon.setImageResource(R.drawable.ic_path);
|
||||||
searchArea.addView(planBtn, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
pathIcon.setColorFilter(Color.WHITE);
|
||||||
|
LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(dp2px(20), dp2px(20));
|
||||||
|
iconParams.rightMargin = dp2px(6); // 图标和文字之间的间距
|
||||||
|
planBtnContainer.addView(pathIcon, iconParams);
|
||||||
|
|
||||||
|
// 添加文字
|
||||||
|
TextView planText = new TextView(context);
|
||||||
|
planText.setText("规划路线");
|
||||||
|
planText.setTextColor(Color.WHITE);
|
||||||
|
planText.setTextSize(16);
|
||||||
|
planText.setTypeface(Typeface.DEFAULT_BOLD);
|
||||||
|
planText.setGravity(Gravity.CENTER);
|
||||||
|
planBtnContainer.addView(planText);
|
||||||
|
|
||||||
|
// 设置点击事件
|
||||||
|
planBtnContainer.setOnClickListener(v -> calculateRouteBeforeNavi());
|
||||||
|
searchArea.addView(planBtnContainer, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
||||||
|
|
||||||
bottomContainer.addView(searchArea);
|
bottomContainer.addView(searchArea);
|
||||||
|
|
||||||
@@ -559,7 +574,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
tvPrice.setText("加氢价格:" + hydrogenPrice);
|
tvPrice.setText("加氢价格:" + hydrogenPrice);
|
||||||
tvPhone.setText("联系方式:" + liaisonPhone);
|
tvPhone.setText("联系方式:" + liaisonPhone);
|
||||||
|
|
||||||
isGetInputtips = false;
|
|
||||||
|
|
||||||
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(endPoint, 13f));
|
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(endPoint, 13f));
|
||||||
|
|
||||||
@@ -727,13 +742,11 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
* 获取货车路线算法信息
|
* 获取货车路线算法信息
|
||||||
*/
|
*/
|
||||||
private void fetchTruckRouteAlgorithm(AMapLocation loc) {
|
private void fetchTruckRouteAlgorithm(AMapLocation loc) {
|
||||||
|
|
||||||
showLoading();
|
|
||||||
|
|
||||||
if (plateNumber == null || plateNumber.isEmpty()) {
|
if (plateNumber == null || plateNumber.isEmpty()) {
|
||||||
|
Toast.makeText(mActivity,"请先绑定车辆后进行导航",Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
showLoading();
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("longitude", String.valueOf(loc.getLongitude()));
|
json.put("longitude", String.valueOf(loc.getLongitude()));
|
||||||
@@ -917,7 +930,7 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
// 简化逻辑,直接设置文本
|
// 简化逻辑,直接设置文本
|
||||||
endInput.post(() -> {
|
endInput.post(() -> {
|
||||||
try {
|
try {
|
||||||
endInput.setText(district != null && !district.isEmpty() ? name + " " + district : name);
|
endInput.setText(district != null && !district.isEmpty() ? (name + " " + district ): name);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Failed to set text to endInput", e);
|
Log.e(TAG, "Failed to set text to endInput", e);
|
||||||
}
|
}
|
||||||
@@ -1142,6 +1155,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|||||||
// 更新 UI 和 业务逻辑
|
// 更新 UI 和 业务逻辑
|
||||||
endName = marker.getTitle();
|
endName = marker.getTitle();
|
||||||
isUserSelectedDestination = true; // 标识用户手动选择了目的地
|
isUserSelectedDestination = true; // 标识用户手动选择了目的地
|
||||||
|
isGetInputtips = false;
|
||||||
|
|
||||||
|
endInput.setText("");
|
||||||
|
|
||||||
// 需要传入当前位置以便接口计算路线
|
// 需要传入当前位置以便接口计算路线
|
||||||
if (mlocationClient != null && mlocationClient.getLastKnownLocation() != null) {
|
if (mlocationClient != null && mlocationClient.getLastKnownLocation() != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user