[2.12.0] opt
BIN
OCH/mogo-och-taxi/src/main/assets/map_style.data
Normal file
BIN
OCH/mogo-och-taxi/src/main/assets/map_style_extra.data
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.mogo.och.taxi.ui;
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/6/24 11:33 上午
|
||||
*/
|
||||
public interface ITaxiMapDirectionView {
|
||||
|
||||
/**
|
||||
* 绘制路径线
|
||||
*/
|
||||
void drawablePolyline();
|
||||
|
||||
/**
|
||||
* 清除路径线
|
||||
*/
|
||||
void clearPolyline();
|
||||
|
||||
/**
|
||||
* 设置路径中起终点marker
|
||||
*/
|
||||
void setLineMarker();
|
||||
}
|
||||
@@ -25,8 +25,6 @@ import com.mogo.och.taxi.model.NaviToDestinationModel;
|
||||
public class TaxiAmapNaviFragment extends BaseTaxiUIFragment implements AMapNaviViewListener, View.OnClickListener {
|
||||
|
||||
private AMapNaviView mAMapNaviView;
|
||||
// private OverviewButtonView mOverviewButtonView;
|
||||
// private NextTurnTipView mNextTurnTipView;
|
||||
private AMap aMap;
|
||||
private ITaxiNaviChangedCallback mNaviToStartInfoCallback; // 前往乘客上车点
|
||||
public static TaxiAmapNaviFragment newInstance() {
|
||||
@@ -40,7 +38,7 @@ public class TaxiAmapNaviFragment extends BaseTaxiUIFragment implements AMapNavi
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.taxi_navi_view;
|
||||
return R.layout.taxi_amap_navi_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,366 @@
|
||||
package com.mogo.och.taxi.ui;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_TAXI;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.maps.model.PolylineOptions;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.och.taxi.R;
|
||||
import com.mogo.och.taxi.utils.TaxiMapAssetStyleUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 乘客屏小地图
|
||||
*/
|
||||
public class TaxiMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoMapLocationListener, ITaxiMapDirectionView, AMap.OnCameraChangeListener {
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "TaxiMapDirectionView";
|
||||
|
||||
private TextureMapView mAMapNaviView;
|
||||
private AMap mAMap;
|
||||
private Marker mCarMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
|
||||
private int zoomLevel = 13;
|
||||
private List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
private int mHaveArrivedIndex;
|
||||
|
||||
List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
List<Integer> texIndexList = new ArrayList<>();
|
||||
|
||||
private BitmapDescriptor mArrivedRes;
|
||||
private BitmapDescriptor mUnArrivedRes;
|
||||
|
||||
public TaxiMapDirectionView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public TaxiMapDirectionView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public TaxiMapDirectionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "initView");
|
||||
|
||||
mContext = context;
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.taxi_map_view, this);
|
||||
|
||||
mAMapNaviView = (TextureMapView) smpView.findViewById(R.id.taxi_amap_view);
|
||||
|
||||
initAMapView();
|
||||
|
||||
// 注册定位监听
|
||||
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
|
||||
}
|
||||
|
||||
private void initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapNaviView.getMap();
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap.setTrafficEnabled(false);
|
||||
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_car))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_view_dir_start)));
|
||||
mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_view_dir_end)));
|
||||
|
||||
mArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_arrived);
|
||||
mUnArrivedRes = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_un_arrive);
|
||||
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
|
||||
// 设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
uiSettings.setZoomControlsEnabled(false);// 地图缩放级别的交换按钮
|
||||
uiSettings.setAllGesturesEnabled(false);// 所有手势
|
||||
uiSettings.setMyLocationButtonEnabled(false); // 显示默认的定位按钮
|
||||
uiSettings.setLogoBottomMargin(-150); //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
|
||||
mAMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + TAG, "smp---onMapLoaded");
|
||||
// 加载自定义样式
|
||||
CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(TaxiMapAssetStyleUtil.getAssetsStyle(getContext(),"map_style.data"))
|
||||
.setStyleExtraData(TaxiMapAssetStyleUtil.getAssetsExtraStyle(getContext(),"map_style_extra.data"));
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(customMapStyleOptions);
|
||||
mAMapNaviView.getMap().setPointToCenter(mAMapNaviView.getWidth() / 2, mAMapNaviView.getHeight() / 2);
|
||||
}
|
||||
});
|
||||
|
||||
//设置地图状态的监听接口
|
||||
mAMap.setOnCameraChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
|
||||
if (location == null){
|
||||
return;
|
||||
}
|
||||
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
//圈定地图显示范围
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
boundsBuilder.include(currentLatLng);
|
||||
boundsBuilder.include(endLatLng);
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100,100,100,100));
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--moveCamera :" + location.getLatitude()+", "+location.getLongitude());
|
||||
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build();
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
//更新车辆位置
|
||||
if (mCarMarker != null) {
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "location.getBearing() = " + location.getBearing());
|
||||
mCarMarker.setRotateAngle(360 - location.getBearing());
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
// CallerLogger.INSTANCE.d(M_TAXI_P + TAG, "onCarLocationChanged2--loacation :" + location.getLatitude()+", "+location.getLongitude());
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLineMarker() {
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
// 设置开始结束Marker位置
|
||||
LatLng startLatLng = mCoordinatesLatLng.get(0);
|
||||
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
||||
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mStartMarker.setVisible(true);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mAMap != null) {
|
||||
|
||||
addRouteColorList();
|
||||
|
||||
if (mCoordinatesLatLng.size() > 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(mCoordinatesLatLng);
|
||||
polylineOptions.setUseTexture(true);
|
||||
polylineOptions.width(15);
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// polylineOptions.setCustomTexture(BitmapDescriptorFactory.fromResource(R.drawable.taxi_p_map_arrow_un_arrive));
|
||||
|
||||
// 绘制线
|
||||
mPolyline = mAMap.addPolyline(polylineOptions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加画线颜色值
|
||||
*/
|
||||
private void addRouteColorList() {
|
||||
textureList.clear();
|
||||
texIndexList.clear();
|
||||
for (int i = 0; i < mCoordinatesLatLng.size(); i++){
|
||||
if (i <= mHaveArrivedIndex){
|
||||
textureList.add(mArrivedRes);
|
||||
}else {
|
||||
textureList.add(mUnArrivedRes);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public LatLng CoordinateConverterFrom84(Context mContext, MogoLatLng mogoLatLng) {
|
||||
CoordinateConverter mCoordinateConverter = new CoordinateConverter(mContext);
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS);
|
||||
mCoordinateConverter.coord(new LatLng(mogoLatLng.lat, mogoLatLng.lon));
|
||||
LatLng latLng = mCoordinateConverter.convert();
|
||||
return latLng;
|
||||
}
|
||||
|
||||
public List<LatLng> CoordinateConverterFrom84ForList(Context mContext, List<MogoLatLng> mogoLatLngList) {
|
||||
List<LatLng> list = new ArrayList<>();
|
||||
for (MogoLatLng m : mogoLatLngList) {
|
||||
LatLng mogoLatLng = CoordinateConverterFrom84(mContext, m);
|
||||
list.add(mogoLatLng);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetPolyine() {
|
||||
mCoordinatesLatLng.clear();
|
||||
if (mPolyline != null) {
|
||||
mPolyline.remove();
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void convert(List<MogoLatLng> coordinates) {
|
||||
mCoordinatesLatLng.clear();
|
||||
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext, coordinates);
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
public void setCoordinatesLatLng(List<LatLng> latLngs, int haveArrivedIndex){
|
||||
mCoordinatesLatLng.clear();
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
mHaveArrivedIndex = haveArrivedIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,9 @@ import com.mogo.och.taxi.model.NaviToDestinationModel;
|
||||
* @author: wangmingjun
|
||||
* @date: 2021/11/30
|
||||
*/
|
||||
public class TaxiRottingNaviFragment extends BaseTaxiUIFragment implements AMapNaviViewListener, View.OnClickListener {
|
||||
public class TaxiRottingNaviFragment extends BaseTaxiUIFragment{
|
||||
|
||||
private AMapNaviView mAMapNaviView;
|
||||
// private OverviewButtonView mOverviewButtonView;
|
||||
// private NextTurnTipView mNextTurnTipView;
|
||||
private AMap aMap;
|
||||
private ITaxiNaviChangedCallback mNaviToStartInfoCallback; // 前往乘客上车点
|
||||
private TaxiMapDirectionView mAMapNaviView;
|
||||
public static TaxiRottingNaviFragment newInstance() {
|
||||
|
||||
Bundle args = new Bundle();
|
||||
@@ -40,7 +36,7 @@ public class TaxiRottingNaviFragment extends BaseTaxiUIFragment implements AMapN
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.taxi_navi_view;
|
||||
return R.layout.taxi_rotting_navi_view;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,88 +47,13 @@ public class TaxiRottingNaviFragment extends BaseTaxiUIFragment implements AMapN
|
||||
|
||||
private void initMapView(View view) {
|
||||
|
||||
mAMapNaviView = view.findViewById(R.id.navi_view);
|
||||
mAMapNaviView.setAMapNaviViewListener(this);
|
||||
//车头向上模式
|
||||
mAMapNaviView.setNaviMode(AMapNaviView.CAR_UP_MODE);
|
||||
aMap = mAMapNaviView.getMap();
|
||||
//关闭地图文字显示
|
||||
aMap.showMapText(false);
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
aMap.setMapType(AMap.MAP_TYPE_NIGHT);
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
aMap.setTrafficEnabled(false);
|
||||
setMapViewOptions();
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (null == getContext()){
|
||||
return;
|
||||
}
|
||||
aMap.setCustomMapStyle(
|
||||
new CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data"))
|
||||
.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data"))
|
||||
);
|
||||
mAMapNaviView = view.findViewById(R.id.rotting_navi_view);
|
||||
|
||||
//设置希望展示的地图缩放级别
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void setMapViewOptions() {
|
||||
AMapNaviViewOptions options = new AMapNaviViewOptions();
|
||||
options.setTilt(0);//设置 2D 模式
|
||||
options.setLayoutVisible(false);//设置导航界面UI是否显示。
|
||||
options.setTrafficBarEnabled(false);//设置路况光柱条是否显示(只适用于驾车导航,需要联网)。
|
||||
options.setAutoLockCar(true);//设置6秒后是否自动锁车
|
||||
options.setAutoDisplayOverview(true);//设置是否自动全览模式,即在算路成功后自动进入全览模式
|
||||
options.setTrafficLine(false);
|
||||
options.setModeCrossDisplayShow(true);//设置是否显示路口放大图(路口模型图)
|
||||
options.setAutoChangeZoom(true);//自动缩放级别
|
||||
options.setCarBitmap(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.taxi_navi_arrow_icon));
|
||||
options.setFourCornersBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.taxi_navi_direction_icon));
|
||||
options.setAutoChangeZoom(true);//设置是否开启动态比例尺 (锁车态下自动进行地图缩放变化)
|
||||
// options.setZoom(18);//14-18
|
||||
// options.setTrafficInfoUpdateEnabled(false);
|
||||
// options.setTrafficLayerEnabled(false);//设置[实时交通图层开关按钮]是否显示(只适用于驾车导航,需要联网)。
|
||||
// options.setCameraInfoUpdateEnabled(false);
|
||||
// options.setCompassEnabled(false);//设置指南针图标否在导航界面显示,默认显示。
|
||||
// options.setLaneInfoShow(false);// 设置是否显示道路信息view
|
||||
// options.setNaviArrowVisible(false);//设置路线转向箭头隐藏和显示
|
||||
// options.setRealCrossDisplayShow(false);//设置是否显示路口放大图(实景图)
|
||||
// options.setRouteListButtonShow(true);//设置导航界面是否显示路线全览按钮。
|
||||
// options.setSettingMenuEnabled(false);//设置菜单按钮是否在导航界面显示。
|
||||
|
||||
RouteOverlayOptions routeOverlayOptions = new RouteOverlayOptions();
|
||||
|
||||
// routeOverlayOptions.setArrowOnTrafficRoute(BitmapFactory.decodeResource(getResources(),R.drawable.custtexture_aolr));
|
||||
routeOverlayOptions.setNormalRoute(BitmapFactory.decodeResource(getResources(), R.drawable.taxi_navi_line_icon));
|
||||
options.setRouteOverlayOptions(routeOverlayOptions);
|
||||
|
||||
mAMapNaviView.setViewOptions(options);
|
||||
}
|
||||
public void goToOverview(){
|
||||
if (mAMapNaviView.isRouteOverviewNow()){
|
||||
mAMapNaviView.recoverLockMode();
|
||||
}else {
|
||||
mAMapNaviView.displayOverview();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// if (v.getId() == R.id.navi_overviewbuttonview){
|
||||
// goToOverview();
|
||||
// }
|
||||
}
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState) {
|
||||
super.initViews(savedInstanceState);
|
||||
mAMapNaviView.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -155,150 +76,5 @@ public class TaxiRottingNaviFragment extends BaseTaxiUIFragment implements AMapN
|
||||
if (mAMapNaviView != null){
|
||||
mAMapNaviView.onDestroy();
|
||||
}
|
||||
|
||||
if (mNaviToStartInfoCallback != null){
|
||||
mNaviToStartInfoCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviSetting() {
|
||||
//底部导航设置点击回调
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviCancel() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviMapMode(int naviMode) {
|
||||
//导航态车头模式,0:车头朝上状态;1:正北朝上模式。
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviTurnClick() {
|
||||
//转弯view的点击回调
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNextRoadClick() {
|
||||
//下一个道路View点击回调
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onScanViewButtonClick() {
|
||||
//全览按钮点击回调
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onLockMap(boolean isLock) {
|
||||
//锁地图状态发生变化时回调
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviViewLoaded() {
|
||||
CallerLogger.INSTANCE.d(M_TAXI + "wlx", "导航页面加载成功");
|
||||
CallerLogger.INSTANCE.d(M_TAXI + "wlx", "请不要使用AMapNaviView.getMap().setOnMapLoadedListener();会overwrite导航SDK内部画线逻辑");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapTypeChanged(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviViewShowMode(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNaviBackClick() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 车道信息说明:
|
||||
* <p>
|
||||
* 0xFF, 无对应车道
|
||||
* 0, 直行
|
||||
* 1, 左转
|
||||
* 2, 直行+左转
|
||||
* 3, 右转
|
||||
* 4, 直行+右转
|
||||
* 5, 左掉头
|
||||
* 6, 左转+右转
|
||||
* 7, 直行+左转+右转
|
||||
* 8, 右掉头
|
||||
* 9, 直行+左掉头
|
||||
* 10, 直行+右掉头
|
||||
* 11, 左转+左掉头
|
||||
* 12, 右转+右掉头
|
||||
* 13, 直行+扩展
|
||||
* 14, 左转+左掉头+扩展
|
||||
* 15, 保留
|
||||
* 16, 直行+左转+左掉头
|
||||
* 17, 右转+左掉头
|
||||
* 18, 左转+右转+左掉头
|
||||
* 19, 直行+右转+左掉头
|
||||
* 20, 左转+右掉头
|
||||
* 21, 公交车道
|
||||
* 22, 空车道
|
||||
* 23 可变车道
|
||||
*/
|
||||
|
||||
String[] array = {
|
||||
"直行车道"
|
||||
, "左转车道"
|
||||
, "左转或直行车道"
|
||||
, "右转车道"
|
||||
, "右转或直行车道"
|
||||
, "左掉头车道"
|
||||
, "左转或者右转车道"
|
||||
, " 左转或右转或直行车道"
|
||||
, "右转掉头车道"
|
||||
, "直行或左转掉头车道"
|
||||
, "直行或右转掉头车道"
|
||||
, "左转或左掉头车道"
|
||||
, "右转或右掉头车道"
|
||||
, "直行并且车道扩展"
|
||||
, "左转+左掉头+扩展"
|
||||
, "不可以选择该车道"
|
||||
, "直行+左转+左掉头车道"
|
||||
, "右转+左掉头"
|
||||
, "左转+右转+左掉头"
|
||||
, "直行+右转+左掉头"
|
||||
, "左转+右掉头"
|
||||
, "公交车道"
|
||||
, "空车道"
|
||||
, "可变车道"
|
||||
};
|
||||
|
||||
String[] actions = {
|
||||
"直行"
|
||||
, "左转"
|
||||
, "左转或直行"
|
||||
, "右转"
|
||||
, "右转或这行"
|
||||
, "左掉头"
|
||||
, "左转或者右转"
|
||||
, " 左转或右转或直行"
|
||||
, "右转掉头"
|
||||
, "直行或左转掉头"
|
||||
, "直行或右转掉头"
|
||||
, "左转或左掉头"
|
||||
, "右转或右掉头"
|
||||
, "直行并且车道扩展"
|
||||
, "左转+左掉头+扩展"
|
||||
, "不可以选择"
|
||||
, "直行+左转+左掉头"
|
||||
, "右转+左掉头"
|
||||
, "左转+右转+左掉头"
|
||||
, "直行+右转+左掉头"
|
||||
, "左转+右掉头"
|
||||
, "公交车道"
|
||||
, "空车道"
|
||||
, "可变车道"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mogo.och.taxi.utils;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 12/18/20 5:37 PM
|
||||
*/
|
||||
public class TaxiMapAssetStyleUtil {
|
||||
|
||||
public static byte[] getAssetsStyle(Context context,String fileName) {
|
||||
byte[] buffer1 = null;
|
||||
InputStream is1 = null;
|
||||
try {
|
||||
is1 = context.getResources().getAssets().open(fileName); //eg. over_view_style.data
|
||||
int lenght1 = is1.available();
|
||||
buffer1 = new byte[lenght1];
|
||||
is1.read(buffer1);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (is1 != null) {
|
||||
is1.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return buffer1;
|
||||
}
|
||||
|
||||
|
||||
public static byte[] getAssetsExtraStyle(Context context, String fileName) {
|
||||
byte[] buffer1 = null;
|
||||
InputStream is1 = null;
|
||||
try {
|
||||
is1 = context.getResources().getAssets().open(fileName); //eg. over_view_style_extra.data
|
||||
int lenght1 = is1.available();
|
||||
buffer1 = new byte[lenght1];
|
||||
is1.read(buffer1);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (is1 != null) {
|
||||
is1.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return buffer1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 588 B |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 588 B |
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 783 B |
|
After Width: | Height: | Size: 588 B |
BIN
OCH/mogo-och-taxi/src/main/res/drawable-xhdpi/taxi_map_car.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="30px"
|
||||
app:cardElevation="8px"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
app:cardBackgroundColor="@android:color/transparent">
|
||||
<com.amap.api.navi.AMapNaviView
|
||||
android:id="@+id/navi_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
17
OCH/mogo-och-taxi/src/main/res/layout/taxi_map_view.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.mogo.och.common.module.wigets.OCHCornerCustomCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:och_card_right_bottom_radius="@dimen/dp_40"
|
||||
app:och_card_left_bottom_radius="@dimen/dp_40"
|
||||
android:background="#00000000">
|
||||
|
||||
<com.amap.api.maps.TextureMapView
|
||||
android:id="@+id/taxi_amap_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#00000000"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
</com.mogo.och.common.module.wigets.OCHCornerCustomCardView>
|
||||
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="30px"
|
||||
app:cardElevation="8px"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
app:cardBackgroundColor="@android:color/transparent">
|
||||
<com.amap.api.navi.AMapNaviView
|
||||
android:id="@+id/navi_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
<!-- <com.amap.api.navi.view.OverviewButtonView-->
|
||||
<!-- android:id="@+id/navi_overviewbuttonview"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:layout_alignParentRight="true" />-->
|
||||
<!-- <com.amap.api.navi.view.DriveWayView-->
|
||||
<!-- android:id="@+id/navi_drivewayview"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"/>-->
|
||||
|
||||
<!-- <com.amap.api.navi.view.NextTurnTipView-->
|
||||
<!-- android:id="@+id/navi_nextturntipview"-->
|
||||
<!-- android:layout_width="100px"-->
|
||||
<!-- android:layout_height="180px"-->
|
||||
<!-- ></com.amap.api.navi.view.NextTurnTipView>-->
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardCornerRadius="30px"
|
||||
app:cardElevation="8px"
|
||||
app:cardUseCompatPadding="true"
|
||||
app:cardPreventCornerOverlap="false"
|
||||
app:cardBackgroundColor="@android:color/transparent">
|
||||
|
||||
<com.mogo.och.taxi.ui.TaxiMapDirectionView
|
||||
android:id="@+id/rotting_navi_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||