|
|
|
|
@@ -5,10 +5,13 @@ import android.content.Context;
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
|
import android.graphics.Color;
|
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
|
import android.graphics.drawable.GradientDrawable;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.os.Handler;
|
|
|
|
|
import android.os.Looper;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.util.TypedValue;
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
@@ -20,6 +23,7 @@ import android.widget.EditText;
|
|
|
|
|
import android.widget.FrameLayout;
|
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.amap.api.location.AMapLocation;
|
|
|
|
|
@@ -43,10 +47,7 @@ import com.amap.api.navi.AmapNaviPage;
|
|
|
|
|
import com.amap.api.navi.AmapNaviParams;
|
|
|
|
|
import com.amap.api.navi.AmapNaviType;
|
|
|
|
|
import com.amap.api.navi.AmapPageType;
|
|
|
|
|
import com.amap.api.navi.INaviInfoCallback;
|
|
|
|
|
import com.amap.api.navi.enums.PathPlanningStrategy;
|
|
|
|
|
import com.amap.api.navi.model.AMapCarInfo;
|
|
|
|
|
import com.amap.api.navi.model.AMapNaviLocation;
|
|
|
|
|
import com.amap.api.services.core.AMapException;
|
|
|
|
|
import com.amap.api.services.core.LatLonPoint;
|
|
|
|
|
import com.amap.api.services.geocoder.GeocodeResult;
|
|
|
|
|
@@ -54,7 +55,11 @@ import com.amap.api.services.geocoder.GeocodeSearch;
|
|
|
|
|
import com.amap.api.services.geocoder.RegeocodeAddress;
|
|
|
|
|
import com.amap.api.services.geocoder.RegeocodeQuery;
|
|
|
|
|
import com.amap.api.services.geocoder.RegeocodeResult;
|
|
|
|
|
import com.amap.api.services.help.Inputtips;
|
|
|
|
|
import com.amap.api.services.help.InputtipsQuery;
|
|
|
|
|
import com.amap.api.services.help.Tip;
|
|
|
|
|
import com.amap.api.services.route.BusRouteResult;
|
|
|
|
|
import com.amap.api.services.route.DrivePath;
|
|
|
|
|
import com.amap.api.services.route.DriveRouteResult;
|
|
|
|
|
import com.amap.api.services.route.RideRouteResult;
|
|
|
|
|
import com.amap.api.services.route.RouteSearch;
|
|
|
|
|
@@ -78,33 +83,33 @@ import okhttp3.RequestBody;
|
|
|
|
|
import okhttp3.Response;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 高德地图导航
|
|
|
|
|
* 高德地图导航 Native View - 底部精简交互优化版
|
|
|
|
|
*/
|
|
|
|
|
public class NativeMapView implements PlatformView, LocationSource, AMapLocationListener,
|
|
|
|
|
GeocodeSearch.OnGeocodeSearchListener, RouteSearch.OnRouteSearchListener, AMap.OnMarkerClickListener {
|
|
|
|
|
GeocodeSearch.OnGeocodeSearchListener, RouteSearch.OnRouteSearchListener, AMap.OnMarkerClickListener, Inputtips.InputtipsListener {
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "NativeMapView";
|
|
|
|
|
private final FrameLayout container;
|
|
|
|
|
|
|
|
|
|
// 地图相关
|
|
|
|
|
private MapView mapView;
|
|
|
|
|
private AMap aMap;
|
|
|
|
|
private OnLocationChangedListener mListener;
|
|
|
|
|
|
|
|
|
|
// 定位相关
|
|
|
|
|
private AMapLocationClient mlocationClient;
|
|
|
|
|
private final Context mContext;
|
|
|
|
|
private Activity mActivity; // 保存Activity引用用于导航
|
|
|
|
|
private Activity mActivity;
|
|
|
|
|
private GeocodeSearch geocoderSearch;
|
|
|
|
|
private RouteSearch routeSearch;
|
|
|
|
|
private final OkHttpClient httpClient = new OkHttpClient();
|
|
|
|
|
|
|
|
|
|
// UI组件
|
|
|
|
|
private EditText startInput;
|
|
|
|
|
private EditText endInput;
|
|
|
|
|
private LinearLayout searchArea; // 规划路线面板
|
|
|
|
|
private LinearLayout detailPanel; // 详情面板
|
|
|
|
|
private TextView tvStationName, tvStationAddr, tvRouteInfo;
|
|
|
|
|
|
|
|
|
|
private LatLng currentLatLng;
|
|
|
|
|
private String startName = "我的位置";
|
|
|
|
|
private String endName = "目的地";
|
|
|
|
|
private String endName = "";
|
|
|
|
|
private LatLng startPoint;
|
|
|
|
|
private LatLng endPoint;
|
|
|
|
|
private boolean isFirstLocation = true;
|
|
|
|
|
@@ -112,8 +117,6 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
|
|
|
|
|
public NativeMapView(Context context, int id, Object args) {
|
|
|
|
|
this.mContext = context;
|
|
|
|
|
|
|
|
|
|
// 尝试获取Activity引用
|
|
|
|
|
mActivity = getActivityFromContext(context);
|
|
|
|
|
|
|
|
|
|
MapsInitializer.updatePrivacyShow(context, true, true);
|
|
|
|
|
@@ -127,24 +130,17 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
mapView.onCreate(null);
|
|
|
|
|
aMap = mapView.getMap();
|
|
|
|
|
|
|
|
|
|
container.addView(mapView, new FrameLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
|
|
container.addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
|
|
|
|
|
|
|
initServices(context);
|
|
|
|
|
initOverlays(context);
|
|
|
|
|
setupMapUi();
|
|
|
|
|
|
|
|
|
|
// 通知MainActivity
|
|
|
|
|
if (context instanceof MainActivity) {
|
|
|
|
|
((MainActivity) context).setMapView(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "NativeMapView初始化完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化服务
|
|
|
|
|
*/
|
|
|
|
|
private void initServices(Context context) {
|
|
|
|
|
try {
|
|
|
|
|
geocoderSearch = new GeocodeSearch(context);
|
|
|
|
|
@@ -156,75 +152,209 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 初始化覆盖层UI
|
|
|
|
|
*/
|
|
|
|
|
private void initOverlays(Context context) {
|
|
|
|
|
LinearLayout searchBox = new LinearLayout(context);
|
|
|
|
|
searchBox.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
searchBox.setBackground(getRoundedDrawable(Color.WHITE, 12));
|
|
|
|
|
searchBox.setElevation(dp2px(8));
|
|
|
|
|
int p = dp2px(15);
|
|
|
|
|
searchBox.setPadding(p, p, p, p);
|
|
|
|
|
searchBox.setClickable(true);
|
|
|
|
|
searchBox.setFocusable(true);
|
|
|
|
|
// --- 底部主容器 (包含两个互斥显示的面板) ---
|
|
|
|
|
LinearLayout bottomContainer = new LinearLayout(context);
|
|
|
|
|
bottomContainer.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
bottomContainer.setGravity(Gravity.BOTTOM);
|
|
|
|
|
|
|
|
|
|
startInput = createInput(context, "起点: 正在定位...");
|
|
|
|
|
searchBox.addView(startInput);
|
|
|
|
|
// 1. 详情面板 (用于显示加氢站详细信息,初始隐藏)
|
|
|
|
|
detailPanel = createDetailPanel(context);
|
|
|
|
|
detailPanel.setVisibility(View.GONE);
|
|
|
|
|
bottomContainer.addView(detailPanel);
|
|
|
|
|
|
|
|
|
|
// 2. 搜索规划面板 (初始显示)
|
|
|
|
|
searchArea = new LinearLayout(context);
|
|
|
|
|
searchArea.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
searchArea.setBackground(getRoundedDrawable(Color.WHITE, 16));
|
|
|
|
|
searchArea.setElevation(dp2px(10));
|
|
|
|
|
int p = dp2px(15);
|
|
|
|
|
searchArea.setPadding(p, p, p, p);
|
|
|
|
|
|
|
|
|
|
endInput = new EditText(context);
|
|
|
|
|
endInput.setHint("请输入目的地,不输入则自动匹配推荐加氢站");
|
|
|
|
|
endInput.setTextSize(13);
|
|
|
|
|
endInput.setHintTextColor(Color.LTGRAY);
|
|
|
|
|
endInput.setPadding(dp2px(12), dp2px(12), dp2px(12), dp2px(12));
|
|
|
|
|
endInput.setBackground(getRoundedDrawable(Color.parseColor("#F8F8F8"), 8));
|
|
|
|
|
endInput.setSingleLine(true);
|
|
|
|
|
endInput.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
|
|
|
|
|
endInput.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
|
|
|
|
@Override public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
if (s.length() > 1) {
|
|
|
|
|
InputtipsQuery query = new InputtipsQuery(s.toString(), "");
|
|
|
|
|
query.setCityLimit(true);
|
|
|
|
|
Inputtips inputtips = new Inputtips(mContext, query);
|
|
|
|
|
inputtips.setInputtipsListener(NativeMapView.this);
|
|
|
|
|
inputtips.requestInputtipsAsyn();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@Override public void afterTextChanged(Editable s) {}
|
|
|
|
|
});
|
|
|
|
|
searchArea.addView(endInput);
|
|
|
|
|
|
|
|
|
|
View vSpace = new View(context);
|
|
|
|
|
searchBox.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(10)));
|
|
|
|
|
searchArea.addView(vSpace, new LinearLayout.LayoutParams(1, dp2px(12)));
|
|
|
|
|
|
|
|
|
|
LinearLayout endRow = new LinearLayout(context);
|
|
|
|
|
endRow.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
|
endRow.setGravity(Gravity.CENTER_VERTICAL);
|
|
|
|
|
Button planBtn = new Button(context);
|
|
|
|
|
planBtn.setText("规划路线");
|
|
|
|
|
planBtn.setTextColor(Color.WHITE);
|
|
|
|
|
planBtn.setTypeface(Typeface.DEFAULT_BOLD);
|
|
|
|
|
planBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 10));
|
|
|
|
|
planBtn.setOnClickListener(v -> calculateRouteBeforeNavi());
|
|
|
|
|
searchArea.addView(planBtn, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48)));
|
|
|
|
|
|
|
|
|
|
endInput = createInput(context, "终点: 请输入目的地");
|
|
|
|
|
endRow.addView(endInput, new LinearLayout.LayoutParams(0, dp2px(42), 1f));
|
|
|
|
|
bottomContainer.addView(searchArea);
|
|
|
|
|
|
|
|
|
|
Button routeBtn = new Button(context);
|
|
|
|
|
routeBtn.setText("路径规划");
|
|
|
|
|
routeBtn.setTextColor(Color.WHITE);
|
|
|
|
|
routeBtn.setAllCaps(false);
|
|
|
|
|
routeBtn.setTextSize(14);
|
|
|
|
|
routeBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 6));
|
|
|
|
|
routeBtn.setOnClickListener(v -> startRouteSearch());
|
|
|
|
|
endRow.addView(routeBtn, new LinearLayout.LayoutParams(dp2px(90), dp2px(42)));
|
|
|
|
|
|
|
|
|
|
searchBox.addView(endRow);
|
|
|
|
|
|
|
|
|
|
FrameLayout.LayoutParams searchParams = new FrameLayout.LayoutParams(
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
searchParams.setMargins(dp2px(15), dp2px(50), dp2px(15), 0);
|
|
|
|
|
container.addView(searchBox, searchParams);
|
|
|
|
|
// 设置统一的底部间距
|
|
|
|
|
FrameLayout.LayoutParams bottomParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
bottomParams.gravity = Gravity.BOTTOM;
|
|
|
|
|
bottomParams.setMargins(dp2px(12), 0, dp2px(12), dp2px(65));
|
|
|
|
|
container.addView(bottomContainer, bottomParams);
|
|
|
|
|
|
|
|
|
|
// --- 右下角定位按钮 ---
|
|
|
|
|
ImageButton locBtn = new ImageButton(context);
|
|
|
|
|
locBtn.setImageResource(android.R.drawable.ic_menu_mylocation);
|
|
|
|
|
locBtn.setBackground(getRoundedDrawable(Color.WHITE, 30));
|
|
|
|
|
locBtn.setBackground(getRoundedDrawable(Color.WHITE, 25));
|
|
|
|
|
locBtn.setElevation(dp2px(4));
|
|
|
|
|
locBtn.setOnClickListener(v -> {
|
|
|
|
|
if (currentLatLng != null) {
|
|
|
|
|
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
|
|
|
|
}
|
|
|
|
|
if (currentLatLng != null) aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 15f));
|
|
|
|
|
});
|
|
|
|
|
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(dp2px(50), dp2px(50));
|
|
|
|
|
locParams.setMargins(0, 0, dp2px(20), dp2px(120));
|
|
|
|
|
FrameLayout.LayoutParams locParams = new FrameLayout.LayoutParams(dp2px(44), dp2px(44));
|
|
|
|
|
locParams.setMargins(0, 0, dp2px(15), dp2px(250)); // 调高一点,避开底部的面板
|
|
|
|
|
locParams.gravity = Gravity.BOTTOM | Gravity.END;
|
|
|
|
|
container.addView(locBtn, locParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private EditText createInput(Context context, String hint) {
|
|
|
|
|
EditText et = new EditText(context);
|
|
|
|
|
et.setHint(hint);
|
|
|
|
|
et.setTextSize(14f);
|
|
|
|
|
et.setTextColor(Color.BLACK);
|
|
|
|
|
et.setPadding(dp2px(12), dp2px(10), dp2px(12), dp2px(10));
|
|
|
|
|
et.setBackground(getRoundedDrawable(Color.parseColor("#F5F5F5"), 6));
|
|
|
|
|
et.setSingleLine(true);
|
|
|
|
|
et.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
|
|
|
|
et.setFocusable(true);
|
|
|
|
|
et.setFocusableInTouchMode(true);
|
|
|
|
|
return et;
|
|
|
|
|
private LinearLayout createDetailPanel(Context context) {
|
|
|
|
|
LinearLayout panel = new LinearLayout(context);
|
|
|
|
|
panel.setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
panel.setBackground(getRoundedDrawable(Color.WHITE, 16));
|
|
|
|
|
panel.setPadding(dp2px(20), dp2px(20), dp2px(20), dp2px(20));
|
|
|
|
|
panel.setElevation(dp2px(12));
|
|
|
|
|
|
|
|
|
|
tvStationName = new TextView(context);
|
|
|
|
|
tvStationName.setTextSize(18);
|
|
|
|
|
tvStationName.setTextColor(Color.BLACK);
|
|
|
|
|
tvStationName.setTypeface(Typeface.DEFAULT_BOLD);
|
|
|
|
|
panel.addView(tvStationName);
|
|
|
|
|
|
|
|
|
|
tvStationAddr = new TextView(context);
|
|
|
|
|
tvStationAddr.setTextSize(13);
|
|
|
|
|
tvStationAddr.setPadding(0, dp2px(4), 0, dp2px(10));
|
|
|
|
|
tvStationAddr.setTextColor(Color.GRAY);
|
|
|
|
|
panel.addView(tvStationAddr);
|
|
|
|
|
|
|
|
|
|
tvRouteInfo = new TextView(context);
|
|
|
|
|
tvRouteInfo.setTextSize(14);
|
|
|
|
|
tvRouteInfo.setTextColor(Color.parseColor("#333333"));
|
|
|
|
|
panel.addView(tvRouteInfo);
|
|
|
|
|
|
|
|
|
|
Button startNaviBtn = new Button(context);
|
|
|
|
|
startNaviBtn.setText("开始导航");
|
|
|
|
|
startNaviBtn.setTextColor(Color.WHITE);
|
|
|
|
|
startNaviBtn.setBackground(getRoundedDrawable(Color.parseColor("#017143"), 10));
|
|
|
|
|
startNaviBtn.setOnClickListener(v -> startRouteSearch());
|
|
|
|
|
|
|
|
|
|
LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dp2px(48));
|
|
|
|
|
btnParams.topMargin = dp2px(15);
|
|
|
|
|
panel.addView(startNaviBtn, btnParams);
|
|
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void calculateRouteBeforeNavi() {
|
|
|
|
|
if (startPoint == null) {
|
|
|
|
|
Toast.makeText(mContext, "正在定位...", Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (endPoint == null) {
|
|
|
|
|
Toast.makeText(mContext, "请先选择目的地", Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 开始规划前隐藏输入框面板
|
|
|
|
|
searchArea.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
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.calculateDriveRouteAsyn(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onGetInputtips(List<Tip> tipList, int rCode) {
|
|
|
|
|
if (rCode == 1000 && tipList != null && !tipList.isEmpty()) {
|
|
|
|
|
Tip tip = tipList.get(0);
|
|
|
|
|
if (tip.getPoint() != null) {
|
|
|
|
|
endPoint = new LatLng(tip.getPoint().getLatitude(), tip.getPoint().getLongitude());
|
|
|
|
|
endName = tip.getName();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDriveRouteSearched(DriveRouteResult result, int rCode) {
|
|
|
|
|
if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && !result.getPaths().isEmpty()) {
|
|
|
|
|
DrivePath path = result.getPaths().get(0);
|
|
|
|
|
|
|
|
|
|
// 规划成功,显示详情面板
|
|
|
|
|
detailPanel.setVisibility(View.VISIBLE);
|
|
|
|
|
tvStationName.setText(endName);
|
|
|
|
|
tvStationAddr.setText(endInput.getText().toString());
|
|
|
|
|
|
|
|
|
|
String info = String.format("预计时间:%d分钟 | 行驶里程:%.1f公里 | 预计路费:%.0f元",
|
|
|
|
|
path.getDuration() / 60, path.getDistance() / 1000f, path.getTolls());
|
|
|
|
|
tvRouteInfo.setText(info);
|
|
|
|
|
|
|
|
|
|
aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(endPoint, 13f));
|
|
|
|
|
} else {
|
|
|
|
|
// 规划失败回退面板
|
|
|
|
|
searchArea.setVisibility(View.VISIBLE);
|
|
|
|
|
Toast.makeText(mContext, "路径规划失败: " + rCode, Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void startRouteSearch() {
|
|
|
|
|
if (mActivity == null || startPoint == null || endPoint == null) return;
|
|
|
|
|
|
|
|
|
|
Poi start = new Poi(startName, startPoint, "");
|
|
|
|
|
Poi end = new Poi(endName, endPoint, "");
|
|
|
|
|
AmapNaviParams params = new AmapNaviParams(start, null, end, AmapNaviType.DRIVER, AmapPageType.ROUTE);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
AMapNavi mAMapNavi = AMapNavi.getInstance(mContext);
|
|
|
|
|
AMapCarInfo carInfo = new AMapCarInfo();
|
|
|
|
|
carInfo.setCarNumber("沪AGK2267");
|
|
|
|
|
carInfo.setCarType("1");
|
|
|
|
|
mAMapNavi.setCarInfo(carInfo);
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
|
|
|
|
|
AmapNaviPage.getInstance().showRouteActivity(mActivity, params, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupMapUi() {
|
|
|
|
|
aMap.setLocationSource(this);
|
|
|
|
|
aMap.setMyLocationEnabled(true);
|
|
|
|
|
aMap.setOnMarkerClickListener(this);
|
|
|
|
|
|
|
|
|
|
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
|
|
|
|
try {
|
|
|
|
|
Bitmap carBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.car);
|
|
|
|
|
if (carBitmap != null) {
|
|
|
|
|
Bitmap scaledBitmap = Bitmap.createScaledBitmap(carBitmap, dp2px(30), dp2px(30), true);
|
|
|
|
|
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
|
|
|
|
|
myLocationStyle.anchor(0.5f, 0.5f);
|
|
|
|
|
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
|
|
|
|
aMap.setMyLocationStyle(myLocationStyle);
|
|
|
|
|
aMap.getUiSettings().setZoomControlsEnabled(false);
|
|
|
|
|
aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private GradientDrawable getRoundedDrawable(int color, int radiusDp) {
|
|
|
|
|
@@ -239,55 +369,9 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, mContext.getResources().getDisplayMetrics());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void setupMapUi() {
|
|
|
|
|
aMap.setLocationSource(this);
|
|
|
|
|
aMap.setMyLocationEnabled(true);
|
|
|
|
|
aMap.setOnMarkerClickListener(this);
|
|
|
|
|
|
|
|
|
|
MyLocationStyle myLocationStyle = new MyLocationStyle();
|
|
|
|
|
|
|
|
|
|
// --- 放大定位图标 ---
|
|
|
|
|
try {
|
|
|
|
|
Bitmap carBitmap = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.car);
|
|
|
|
|
if (carBitmap != null) {
|
|
|
|
|
// 放大到 80dp
|
|
|
|
|
int iconSize = dp2px(25);
|
|
|
|
|
Bitmap scaledBitmap = Bitmap.createScaledBitmap(carBitmap, iconSize, iconSize, true);
|
|
|
|
|
myLocationStyle.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Log.e(TAG, "设置大图标失败", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myLocationStyle.anchor(0.5f, 0.5f);
|
|
|
|
|
myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
|
|
|
|
myLocationStyle.showMyLocation(true);
|
|
|
|
|
myLocationStyle.strokeColor(Color.TRANSPARENT);
|
|
|
|
|
myLocationStyle.radiusFillColor(Color.TRANSPARENT);
|
|
|
|
|
aMap.setMyLocationStyle(myLocationStyle);
|
|
|
|
|
|
|
|
|
|
aMap.getUiSettings().setZoomControlsEnabled(true);
|
|
|
|
|
aMap.getUiSettings().setScaleControlsEnabled(true);
|
|
|
|
|
aMap.getUiSettings().setLogoPosition(AMapOptions.LOGO_POSITION_BOTTOM_LEFT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== LocationSource 接口实现 ====================
|
|
|
|
|
@Override
|
|
|
|
|
public void activate(OnLocationChangedListener listener) {
|
|
|
|
|
mListener = listener;
|
|
|
|
|
startLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void deactivate() {
|
|
|
|
|
mListener = null;
|
|
|
|
|
if (mlocationClient != null) {
|
|
|
|
|
mlocationClient.stopLocation();
|
|
|
|
|
mlocationClient.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
mlocationClient = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override public void activate(OnLocationChangedListener listener) { mListener = listener; startLocation(); }
|
|
|
|
|
@Override public void deactivate() { mListener = null; if (mlocationClient != null) mlocationClient.stopLocation(); }
|
|
|
|
|
|
|
|
|
|
public void startLocation() {
|
|
|
|
|
if (mlocationClient == null) {
|
|
|
|
|
try {
|
|
|
|
|
@@ -297,135 +381,49 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
option.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
|
|
|
|
|
mlocationClient.setLocationOption(option);
|
|
|
|
|
mlocationClient.startLocation();
|
|
|
|
|
Log.d(TAG, "定位启动成功");
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Log.e(TAG, "定位启动失败", e);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLocationChanged(AMapLocation loc) {
|
|
|
|
|
if (loc != null) {
|
|
|
|
|
if (mListener != null) {
|
|
|
|
|
mListener.onLocationChanged(loc);
|
|
|
|
|
}
|
|
|
|
|
if (loc != null && loc.getErrorCode() == 0) {
|
|
|
|
|
currentLatLng = new LatLng(loc.getLatitude(), loc.getLongitude());
|
|
|
|
|
|
|
|
|
|
if (loc.getErrorCode() == 0) {
|
|
|
|
|
if (isFirstLocation) {
|
|
|
|
|
isFirstLocation = false;
|
|
|
|
|
startPoint = currentLatLng;
|
|
|
|
|
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 14f));
|
|
|
|
|
getAddressByLatlng(currentLatLng);
|
|
|
|
|
fetchRecommendStation(loc);
|
|
|
|
|
fetchNearbyStations(loc);
|
|
|
|
|
}
|
|
|
|
|
if (mListener != null) mListener.onLocationChanged(loc);
|
|
|
|
|
if (isFirstLocation) {
|
|
|
|
|
isFirstLocation = false;
|
|
|
|
|
startPoint = currentLatLng;
|
|
|
|
|
aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, 14f));
|
|
|
|
|
getAddressByLatlng(currentLatLng);
|
|
|
|
|
fetchRecommendStation(loc);
|
|
|
|
|
fetchNearbyStations(loc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 逆地理编码 ====================
|
|
|
|
|
private void getAddressByLatlng(LatLng latLng) {
|
|
|
|
|
LatLonPoint point = new LatLonPoint(latLng.latitude, latLng.longitude);
|
|
|
|
|
RegeocodeQuery query = new RegeocodeQuery(point, 200, GeocodeSearch.AMAP);
|
|
|
|
|
geocoderSearch.getFromLocationAsyn(query);
|
|
|
|
|
geocoderSearch.getFromLocationAsyn(new RegeocodeQuery(new LatLonPoint(latLng.latitude, latLng.longitude), 200, GeocodeSearch.AMAP));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
|
|
|
|
|
if (rCode == AMapException.CODE_AMAP_SUCCESS && result != null && result.getRegeocodeAddress() != null) {
|
|
|
|
|
if (rCode == 1000 && result != null) {
|
|
|
|
|
RegeocodeAddress addr = result.getRegeocodeAddress();
|
|
|
|
|
String fullAddr = addr.getFormatAddress();
|
|
|
|
|
|
|
|
|
|
// 优化地址显示逻辑
|
|
|
|
|
startName = formatAddress(fullAddr,result);
|
|
|
|
|
|
|
|
|
|
new Handler(Looper.getMainLooper()).post(() -> {
|
|
|
|
|
startInput.setText(startName);
|
|
|
|
|
startInput.setSelection(startName.length()); // 光标移到末尾
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Log.d(TAG, "逆地理编码成功: " + startName);
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "逆地理编码失败: code=" + rCode + ", result=" + (result != null ? "null" : "has data"));
|
|
|
|
|
startName = addr.getStreetNumber() != null ? addr.getStreetNumber().getStreet() : addr.getDistrict();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化地址显示,移除重复的前缀并限制长度
|
|
|
|
|
*/
|
|
|
|
|
private String formatAddress(String fullAddress,RegeocodeResult result) {
|
|
|
|
|
if (fullAddress == null || fullAddress.isEmpty()) {
|
|
|
|
|
return "未知地点";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取各级地址信息
|
|
|
|
|
String province = null;
|
|
|
|
|
String city = null;
|
|
|
|
|
String district = null;
|
|
|
|
|
String township = null;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
if (result.getRegeocodeAddress() != null) {
|
|
|
|
|
RegeocodeAddress addr = result.getRegeocodeAddress();
|
|
|
|
|
province = addr.getProvince();
|
|
|
|
|
city = addr.getCity();
|
|
|
|
|
district = addr.getDistrict();
|
|
|
|
|
township = addr.getTownship();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Log.e(TAG, "获取地址信息失败", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String formattedAddr = fullAddress;
|
|
|
|
|
|
|
|
|
|
// 按优先级移除重复前缀(省、市、区、乡)
|
|
|
|
|
String[] prefixes = {province, city, district, township};
|
|
|
|
|
for (String prefix : prefixes) {
|
|
|
|
|
if (prefix != null && !prefix.isEmpty() && formattedAddr.startsWith(prefix)) {
|
|
|
|
|
formattedAddr = formattedAddr.substring(prefix.length());
|
|
|
|
|
Log.d(TAG, "移除前缀: " + prefix + " -> " + formattedAddr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 限制地址长度并添加省略号
|
|
|
|
|
if (formattedAddr.length() > 25) {
|
|
|
|
|
formattedAddr = formattedAddr.substring(0, 25) + "...";
|
|
|
|
|
Log.d(TAG, "地址长度截断: " + formattedAddr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return formattedAddr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onGeocodeSearched(GeocodeResult result, int rCode) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== API请求 ====================
|
|
|
|
|
|
|
|
|
|
private void fetchRecommendStation(AMapLocation loc) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("province", loc.getProvince() != null ? loc.getProvince() : "");
|
|
|
|
|
json.put("city", loc.getCity() != null && !loc.getCity().isEmpty() ? loc.getCity() : "");
|
|
|
|
|
json.put("district", loc.getDistrict() != null ? loc.getDistrict() : "");
|
|
|
|
|
json.put("longitude", String.valueOf(loc.getLongitude()));
|
|
|
|
|
json.put("latitude", String.valueOf(loc.getLatitude()));
|
|
|
|
|
json.put("province", loc.getProvince());
|
|
|
|
|
json.put("city", loc.getCity().isEmpty() ? loc.getProvince() : loc.getCity());
|
|
|
|
|
json.put("longitude", loc.getLongitude());
|
|
|
|
|
json.put("latitude", loc.getLatitude());
|
|
|
|
|
|
|
|
|
|
RequestBody body = RequestBody.create(json.toString(), MediaType.parse("application/json; charset=utf-8"));
|
|
|
|
|
Request request = new Request.Builder()
|
|
|
|
|
.url("https://beta-esg.api.lnh2e.com/appointment/station/getStationInfoByArea")
|
|
|
|
|
.post(body)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
httpClient.newCall(request).enqueue(new Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
|
|
|
httpClient.newCall(new Request.Builder().url("https://beta-esg.api.lnh2e.com/appointment/station/getStationInfoByArea").post(RequestBody.create(json.toString(), MediaType.parse("application/json"))).build()).enqueue(new Callback() {
|
|
|
|
|
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) {}
|
|
|
|
|
@Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject res = new JSONObject(response.body().string());
|
|
|
|
|
@@ -439,68 +437,43 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
markStation(endPoint, endName, true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fetchNearbyStations(AMapLocation loc) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("longitude", String.valueOf(loc.getLongitude()));
|
|
|
|
|
json.put("latitude", String.valueOf(loc.getLatitude()));
|
|
|
|
|
json.put("longitude", loc.getLongitude());
|
|
|
|
|
json.put("latitude", loc.getLatitude());
|
|
|
|
|
|
|
|
|
|
RequestBody body = RequestBody.create(json.toString(), MediaType.parse("application/json; charset=utf-8"));
|
|
|
|
|
Request request = new Request.Builder()
|
|
|
|
|
.url("https://beta-esg.api.lnh2e.com/appointment/station/getNearbyHydrogenStationsByLocation")
|
|
|
|
|
.post(body)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
httpClient.newCall(request).enqueue(new Callback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onFailure(@NonNull Call call, @NonNull IOException e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
|
|
|
httpClient.newCall(new Request.Builder().url("https://beta-esg.api.lnh2e.com/appointment/station/getNearbyHydrogenStationsByLocation").post(RequestBody.create(json.toString(), MediaType.parse("application/json"))).build()).enqueue(new Callback() {
|
|
|
|
|
@Override public void onFailure(@NonNull Call call, @NonNull IOException e) {}
|
|
|
|
|
@Override public void onResponse(@NonNull Call call, @NonNull Response response) throws IOException {
|
|
|
|
|
if (response.isSuccessful() && response.body() != null) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject res = new JSONObject(response.body().string());
|
|
|
|
|
if (res.getInt("code") == 0 && !res.isNull("data")) {
|
|
|
|
|
JSONArray array = res.getJSONArray("data");
|
|
|
|
|
new Handler(Looper.getMainLooper()).post(() -> {
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject item = array.getJSONObject(i);
|
|
|
|
|
markStation(new LatLng(item.getDouble("latitude"), item.getDouble("longitude")),
|
|
|
|
|
item.getString("name"), false);
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
JSONArray array = res.getJSONArray("data");
|
|
|
|
|
new Handler(Looper.getMainLooper()).post(() -> {
|
|
|
|
|
for (int i = 0; i < array.length(); i++) {
|
|
|
|
|
try {
|
|
|
|
|
JSONObject item = array.getJSONObject(i);
|
|
|
|
|
markStation(new LatLng(item.getDouble("latitude"), item.getDouble("longitude")), item.getString("name"), false);
|
|
|
|
|
} catch (Exception ignored) {}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) { e.printStackTrace(); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void markStation(LatLng latLng, String name, boolean isRecommend) {
|
|
|
|
|
MarkerOptions opt = new MarkerOptions()
|
|
|
|
|
.position(latLng).title(name)
|
|
|
|
|
.icon(BitmapDescriptorFactory.defaultMarker(isRecommend ? BitmapDescriptorFactory.HUE_RED : BitmapDescriptorFactory.HUE_GREEN));
|
|
|
|
|
Marker m = aMap.addMarker(opt);
|
|
|
|
|
Marker m = aMap.addMarker(new MarkerOptions().position(latLng).title(name).icon(BitmapDescriptorFactory.defaultMarker(isRecommend ? BitmapDescriptorFactory.HUE_RED : BitmapDescriptorFactory.HUE_GREEN)));
|
|
|
|
|
m.setObject(latLng);
|
|
|
|
|
stationMarkers.add(m);
|
|
|
|
|
}
|
|
|
|
|
@@ -511,185 +484,28 @@ public class NativeMapView implements PlatformView, LocationSource, AMapLocation
|
|
|
|
|
endPoint = (LatLng) marker.getObject();
|
|
|
|
|
endName = marker.getTitle();
|
|
|
|
|
endInput.setText(endName);
|
|
|
|
|
startRouteSearch();
|
|
|
|
|
calculateRouteBeforeNavi();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ==================== 路径规划 ====================
|
|
|
|
|
|
|
|
|
|
private void startRouteSearch() {
|
|
|
|
|
if (startPoint == null || endPoint == null) {
|
|
|
|
|
Toast.makeText(mContext, "正在定位中,请稍后...", Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Poi start = new Poi(startName, startPoint, "");
|
|
|
|
|
Poi end = new Poi(endName, endPoint, "");
|
|
|
|
|
|
|
|
|
|
AmapNaviParams params = new AmapNaviParams(start, null, end, AmapNaviType.DRIVER, AmapPageType.ROUTE);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
AMapNavi mAMapNavi = AMapNavi.getInstance(mContext);
|
|
|
|
|
AMapCarInfo carInfo = new AMapCarInfo();
|
|
|
|
|
carInfo.setCarNumber("沪AGK2267");
|
|
|
|
|
carInfo.setCarType("1");
|
|
|
|
|
carInfo.setVehicleAxis("6");
|
|
|
|
|
carInfo.setVehicleHeight("3.32");
|
|
|
|
|
carInfo.setVehicleLength("6.9");
|
|
|
|
|
carInfo.setVehicleWidth("2.26");
|
|
|
|
|
carInfo.setVehicleSize("2");
|
|
|
|
|
carInfo.setVehicleLoad("4.5");
|
|
|
|
|
carInfo.setVehicleWeight("4.5");
|
|
|
|
|
carInfo.setRestriction(true);
|
|
|
|
|
carInfo.setVehicleLoadSwitch(true);
|
|
|
|
|
mAMapNavi.setCarInfo(carInfo);
|
|
|
|
|
} catch (com.amap.api.maps.AMapException e) {
|
|
|
|
|
Log.e(TAG, "设置车辆信息失败", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
params.setRouteStrategy(PathPlanningStrategy.DRIVING_MULTIPLE_ROUTES_DEFAULT);
|
|
|
|
|
|
|
|
|
|
if (mActivity != null) {
|
|
|
|
|
AmapNaviPage.getInstance().showRouteActivity(mActivity, params, new INaviInfoCallback() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onInitNaviFailure() {
|
|
|
|
|
Log.e(TAG, "导航初始化失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onGetNavigationText(String s) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLocationChange(AMapNaviLocation location) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onArriveDestination(boolean b) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStartNavi(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCalculateRouteSuccess(int[] ints) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCalculateRouteFailure(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStopSpeaking() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onReCalculateRoute(int i) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onArrivedWayPoint(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onExitPage(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStrategyChanged(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onMapTypeChanged(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onNaviDirectionChanged(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDayAndNightModeChanged(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBroadcastModeChanged(int i) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onScaleAutoChanged(boolean b) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View getCustomNaviBottomView() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View getCustomNaviView() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View getCustomMiddleView() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDriveRouteSearched(DriveRouteResult result, int rCode) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBusRouteSearched(BusRouteResult r, int c) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onWalkRouteSearched(WalkRouteResult r, int c) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onRideRouteSearched(RideRouteResult r, int c) {
|
|
|
|
|
}
|
|
|
|
|
@Override public void onGeocodeSearched(GeocodeResult r, int c) {}
|
|
|
|
|
@Override public void onBusRouteSearched(BusRouteResult r, int c) {}
|
|
|
|
|
@Override public void onWalkRouteSearched(WalkRouteResult r, int c) {}
|
|
|
|
|
@Override public void onRideRouteSearched(RideRouteResult r, int c) {}
|
|
|
|
|
|
|
|
|
|
private Activity getActivityFromContext(Context context) {
|
|
|
|
|
if (context instanceof Activity)
|
|
|
|
|
return (Activity) context;
|
|
|
|
|
if (context instanceof android.content.ContextWrapper) {
|
|
|
|
|
Context base = ((android.content.ContextWrapper) context).getBaseContext();
|
|
|
|
|
if (base instanceof Activity)
|
|
|
|
|
return (Activity) base;
|
|
|
|
|
}
|
|
|
|
|
if (context instanceof Activity) return (Activity) context;
|
|
|
|
|
if (context instanceof android.content.ContextWrapper) return getActivityFromContext(((android.content.ContextWrapper) context).getBaseContext());
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
|
mapView.onResume();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onPause() {
|
|
|
|
|
mapView.onPause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onSaveInstanceState(Bundle out) {
|
|
|
|
|
mapView.onSaveInstanceState(out);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public View getView() {
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void dispose() {
|
|
|
|
|
if (mlocationClient != null) {
|
|
|
|
|
mlocationClient.stopLocation();
|
|
|
|
|
mlocationClient.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
public void onResume() { mapView.onResume(); }
|
|
|
|
|
public void onPause() { mapView.onPause(); }
|
|
|
|
|
public void onSaveInstanceState(Bundle out) { mapView.onSaveInstanceState(out); }
|
|
|
|
|
@Override public View getView() { return container; }
|
|
|
|
|
@Override public void dispose() {
|
|
|
|
|
if (mlocationClient != null) { mlocationClient.stopLocation(); mlocationClient.onDestroy(); }
|
|
|
|
|
mapView.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|