含测试代码
This commit is contained in:
@@ -31,8 +31,13 @@ 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.amap.api.navi.AMapNavi;
|
||||
import com.amap.api.navi.AMapNaviListener;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.AMapNaviViewListener;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.amap.api.navi.ParallelRoadListener;
|
||||
import com.amap.api.navi.enums.AMapNaviParallelRoadStatus;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.amap.api.navi.model.RouteOverlayOptions;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
@@ -58,24 +63,28 @@ import java.util.List;
|
||||
*/
|
||||
public class SmallMapDirectionView
|
||||
extends RelativeLayout
|
||||
implements IMoGoMapLocationListener, ISmallMapDirectionView {
|
||||
implements IMoGoMapLocationListener, ISmallMapDirectionView,ParallelRoadListener{
|
||||
|
||||
//小地图名称
|
||||
public static final String TAG = "SmallMapDirectionView";
|
||||
|
||||
private RoundLayout rlSmallMapBorder;
|
||||
private AMapNaviView mAMapNaviView;
|
||||
protected AMapNavi mAMapNavi;
|
||||
private AMap mAMap;
|
||||
// private Marker mCarMarker;
|
||||
// private Marker mCarMarker;
|
||||
// private Marker mStartMarker;
|
||||
// private Marker mEndMarker;
|
||||
|
||||
protected NaviLatLng mEndLatlng = new NaviLatLng(40.032969, 116.313151);
|
||||
protected NaviLatLng mStartLatlng = new NaviLatLng(40.106731, 116.248692);
|
||||
protected final List<NaviLatLng> sList = new ArrayList<NaviLatLng>();
|
||||
protected final List<NaviLatLng> eList = new ArrayList<NaviLatLng>();
|
||||
|
||||
private int zoomLevel = 15;
|
||||
private final List<LatLng> mCoordinatesLatLng = new ArrayList<>();
|
||||
private final List<MogoLatLng> mCoordinatesLatLngCurrent = new ArrayList<>();
|
||||
protected List<NaviLatLng> mWayPointList = new ArrayList<NaviLatLng>();
|
||||
|
||||
private Polyline mPolyline;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
@@ -99,9 +108,22 @@ public class SmallMapDirectionView
|
||||
|
||||
private void initView(Context context) {
|
||||
mContext = context;
|
||||
sList.add(mStartLatlng);
|
||||
eList.add(mEndLatlng);
|
||||
mWayPointList.add(new NaviLatLng(40.048674, 116.308173));
|
||||
mWayPointList.add(new NaviLatLng(40.056558, 116.303023));
|
||||
mWayPointList.add(new NaviLatLng(40.069039, 116.2965));
|
||||
mWayPointList.add(new NaviLatLng(40.084144, 116.28311));
|
||||
mWayPointList.add(new NaviLatLng(40.089529, 116.275042));
|
||||
mWayPointList.add(new NaviLatLng(40.099115, 116.258391));
|
||||
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this);
|
||||
|
||||
mAMapNaviView = smpView.findViewById(R.id.aMapNaviView);
|
||||
mAMapNavi = AMapNavi.getInstance(context);
|
||||
// mAMapNavi.addAMapNaviListener((AMapNaviListener) this);
|
||||
mAMapNavi.addParallelRoadListener(this);
|
||||
mAMapNavi.setUseInnerVoice(true, true);
|
||||
// rlSmallMapBorder = findViewById(R.id.rlSmallMapBorder);
|
||||
// rlSmallMapBorder.addView(mAMapNaviView);
|
||||
|
||||
@@ -195,6 +217,15 @@ public class SmallMapDirectionView
|
||||
// });
|
||||
//设置全览模式
|
||||
mAMapNaviView.displayOverview();
|
||||
|
||||
int strategy = 0;
|
||||
try {
|
||||
//再次强调,最后一个参数为true时代表多路径,否则代表单路径
|
||||
strategy = mAMapNavi.strategyConvert(true, false, false, false, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy);
|
||||
}
|
||||
|
||||
|
||||
@@ -398,4 +429,10 @@ public class SmallMapDirectionView
|
||||
mCoordinatesLatLng.addAll(latLngs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyParallelRoad(AMapNaviParallelRoadStatus aMapNaviParallelRoadStatus) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<dimen name="module_map_display_overview_right_margin">100px</dimen>
|
||||
|
||||
<dimen name="module_small_map_padding">30px</dimen>
|
||||
<dimen name="module_small_map_view_border_width">488px</dimen>
|
||||
<dimen name="module_small_map_border_view_width">450px</dimen>
|
||||
<dimen name="module_small_map_view_width">460px</dimen>
|
||||
<dimen name="module_small_map_view_border_width">588px</dimen>
|
||||
<dimen name="module_small_map_border_view_width">550px</dimen>
|
||||
<dimen name="module_small_map_view_width">560px</dimen>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user