Commit 95faa96576e1b342f118ec95989b145b8092cee8
1 parent
8a5cfced
1.分离百度地图
Showing
12 changed files
with
301 additions
and
22 deletions
app/build.gradle
| @@ -76,4 +76,7 @@ dependencies { | @@ -76,4 +76,7 @@ dependencies { | ||
| 76 | implementation "com.alibaba:arouter-api:$rootProject.arouterApiVersion" | 76 | implementation "com.alibaba:arouter-api:$rootProject.arouterApiVersion" |
| 77 | annotationProcessor "com.alibaba:arouter-compiler:$rootProject.arouterCompilerVersion" | 77 | annotationProcessor "com.alibaba:arouter-compiler:$rootProject.arouterCompilerVersion" |
| 78 | implementation 'com.android.support:design:28.0.0' | 78 | implementation 'com.android.support:design:28.0.0' |
| 79 | + | ||
| 80 | + implementation project(':library_baidumap') | ||
| 81 | + | ||
| 79 | } | 82 | } |
app/src/main/java/com/example/modulepedometer/MyApp.java
| @@ -3,6 +3,8 @@ package com.example.modulepedometer; | @@ -3,6 +3,8 @@ package com.example.modulepedometer; | ||
| 3 | import android.app.Application; | 3 | import android.app.Application; |
| 4 | 4 | ||
| 5 | import com.alibaba.android.arouter.launcher.ARouter; | 5 | import com.alibaba.android.arouter.launcher.ARouter; |
| 6 | +import com.baidu.mapapi.CoordType; | ||
| 7 | +import com.baidu.mapapi.SDKInitializer; | ||
| 6 | import com.cnlive.libs.base.application.AppConfig; | 8 | import com.cnlive.libs.base.application.AppConfig; |
| 7 | 9 | ||
| 8 | public class MyApp extends Application { | 10 | public class MyApp extends Application { |
| @@ -14,7 +16,11 @@ public class MyApp extends Application { | @@ -14,7 +16,11 @@ public class MyApp extends Application { | ||
| 14 | 0, BuildConfig.DEBUG, "", "", | 16 | 0, BuildConfig.DEBUG, "", "", |
| 15 | userId, "", "", "", ""); | 17 | userId, "", "", "", ""); |
| 16 | initARouter(); | 18 | initARouter(); |
| 17 | - | 19 | + //在使用SDK各组件之前初始化context信息,传入ApplicationContext |
| 20 | + SDKInitializer.initialize(getApplicationContext()); | ||
| 21 | + //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型. | ||
| 22 | + //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。 | ||
| 23 | + SDKInitializer.setCoordType(CoordType.GCJ02); | ||
| 18 | } | 24 | } |
| 19 | 25 | ||
| 20 | /** | 26 | /** |
moudle_pedometer/src/main/assets/Icon_road_blue_arrow.png
0 → 100644
423 Bytes
moudle_pedometer/src/main/assets/Icon_road_green_arrow.png
0 → 100644
449 Bytes
moudle_pedometer/src/main/assets/Icon_road_nofocus.png
0 → 100644
112 Bytes
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/frame/view/RunRaceDetailFragmentView.java
| @@ -10,6 +10,7 @@ import android.hardware.SensorEventListener; | @@ -10,6 +10,7 @@ import android.hardware.SensorEventListener; | ||
| 10 | import android.hardware.SensorManager; | 10 | import android.hardware.SensorManager; |
| 11 | import android.util.Log; | 11 | import android.util.Log; |
| 12 | import android.view.View; | 12 | import android.view.View; |
| 13 | +import android.widget.Toast; | ||
| 13 | 14 | ||
| 14 | import com.baidu.location.BDAbstractLocationListener; | 15 | import com.baidu.location.BDAbstractLocationListener; |
| 15 | import com.baidu.location.BDLocation; | 16 | import com.baidu.location.BDLocation; |
| @@ -24,8 +25,22 @@ import com.baidu.mapapi.map.MapView; | @@ -24,8 +25,22 @@ import com.baidu.mapapi.map.MapView; | ||
| 24 | import com.baidu.mapapi.map.MarkerOptions; | 25 | import com.baidu.mapapi.map.MarkerOptions; |
| 25 | import com.baidu.mapapi.map.MyLocationConfiguration; | 26 | import com.baidu.mapapi.map.MyLocationConfiguration; |
| 26 | import com.baidu.mapapi.map.MyLocationData; | 27 | import com.baidu.mapapi.map.MyLocationData; |
| 28 | +import com.baidu.mapapi.map.Overlay; | ||
| 29 | +import com.baidu.mapapi.map.OverlayOptions; | ||
| 30 | +import com.baidu.mapapi.map.PolylineOptions; | ||
| 27 | import com.baidu.mapapi.map.UiSettings; | 31 | import com.baidu.mapapi.map.UiSettings; |
| 28 | import com.baidu.mapapi.model.LatLng; | 32 | import com.baidu.mapapi.model.LatLng; |
| 33 | +import com.baidu.mapapi.search.core.SearchResult; | ||
| 34 | +import com.baidu.mapapi.search.route.BikingRouteResult; | ||
| 35 | +import com.baidu.mapapi.search.route.DrivingRouteResult; | ||
| 36 | +import com.baidu.mapapi.search.route.IndoorRouteResult; | ||
| 37 | +import com.baidu.mapapi.search.route.MassTransitRouteResult; | ||
| 38 | +import com.baidu.mapapi.search.route.OnGetRoutePlanResultListener; | ||
| 39 | +import com.baidu.mapapi.search.route.PlanNode; | ||
| 40 | +import com.baidu.mapapi.search.route.RoutePlanSearch; | ||
| 41 | +import com.baidu.mapapi.search.route.TransitRouteResult; | ||
| 42 | +import com.baidu.mapapi.search.route.WalkingRoutePlanOption; | ||
| 43 | +import com.baidu.mapapi.search.route.WalkingRouteResult; | ||
| 29 | import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; | 44 | import com.cnlive.moudle.pedometer.ui.activity.PedometerMainActivity; |
| 30 | import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; | 45 | import com.cnlive.moudle.pedometer.ui.activity.RaceRecordActivity; |
| 31 | import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; | 46 | import com.cnlive.moudle.pedometer.ui.activity.RegistrationInfoActivity; |
| @@ -38,8 +53,12 @@ import com.example.moudle_pedometer.R; | @@ -38,8 +53,12 @@ import com.example.moudle_pedometer.R; | ||
| 38 | import com.hannesdorfmann.mosby3.mvp.MvpView; | 53 | import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 39 | import com.sothree.slidinguppanel.SlidingUpPanelLayout; | 54 | import com.sothree.slidinguppanel.SlidingUpPanelLayout; |
| 40 | 55 | ||
| 56 | +import java.io.LineNumberReader; | ||
| 57 | +import java.util.ArrayList; | ||
| 58 | +import java.util.List; | ||
| 59 | + | ||
| 41 | public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | 60 | public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { |
| 42 | - private static final String TAG = "RunRaceDetailFragmentView"; | 61 | + private static final String TAG = "RunRaceDetailView"; |
| 43 | 62 | ||
| 44 | private RunRaceDetailFragment fragment; | 63 | private RunRaceDetailFragment fragment; |
| 45 | private BaiduMap baiduMap; | 64 | private BaiduMap baiduMap; |
| @@ -52,6 +71,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -52,6 +71,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 52 | private static MyLocationData mylocation; | 71 | private static MyLocationData mylocation; |
| 53 | boolean isFirstLoc = true; // 是否首次定位 | 72 | boolean isFirstLoc = true; // 是否首次定位 |
| 54 | private MarkerOptions currentMark; | 73 | private MarkerOptions currentMark; |
| 74 | + private MarkerOptions endMark; | ||
| 75 | + private MarkerOptions startMark; | ||
| 76 | + | ||
| 55 | private LatLng firstLatLng; | 77 | private LatLng firstLatLng; |
| 56 | private Double lastX = 0.0; | 78 | private Double lastX = 0.0; |
| 57 | private int mCurrentDirection = 0; | 79 | private int mCurrentDirection = 0; |
| @@ -62,6 +84,16 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -62,6 +84,16 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 62 | private LocationClient mLocClient; | 84 | private LocationClient mLocClient; |
| 63 | public MyLocationListenner myListener = new MyLocationListenner(); | 85 | public MyLocationListenner myListener = new MyLocationListenner(); |
| 64 | private final int DEFULT_ZOOM = 17; | 86 | private final int DEFULT_ZOOM = 17; |
| 87 | + private RoutePlanSearch routePlanSearch = null; // 路线规划 | ||
| 88 | + private LatLng endLatLng; | ||
| 89 | + private final int START_MARK = 0;//起始点 | ||
| 90 | + private final int END_MARK = 1;//终止点 | ||
| 91 | + | ||
| 92 | + private String startPoint = "首都师范大学南门"; | ||
| 93 | + private String endPoint = "首都师范大学篮球场"; | ||
| 94 | + | ||
| 95 | + private List<LatLng> importLatLngs;//关键点 | ||
| 96 | + private LatLng startLatLng = new LatLng(39.934266, 116.309228);//起始点 | ||
| 65 | 97 | ||
| 66 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { | 98 | public RunRaceDetailFragmentView(RunRaceDetailFragment fragment) { |
| 67 | this.fragment = fragment; | 99 | this.fragment = fragment; |
| @@ -76,6 +108,37 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -76,6 +108,37 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 76 | return; | 108 | return; |
| 77 | } | 109 | } |
| 78 | initMap(); | 110 | initMap(); |
| 111 | + //初始化运营人员所选的关键点 | ||
| 112 | + importLatLngs = new ArrayList<>(); | ||
| 113 | + //北轨山区社区 | ||
| 114 | +// importLatLngs.add(new LatLng(39.933295, 116.308663)); | ||
| 115 | + //中国体育彩票 | ||
| 116 | + importLatLngs.add(new LatLng(39.933065, 116.309838)); | ||
| 117 | + //花园桥招待所 | ||
| 118 | + importLatLngs.add(new LatLng(39.933094, 116.310927)); | ||
| 119 | +// //砂锅时代问题 | ||
| 120 | +// importLatLngs.add(new LatLng(39.933481, 116.311834)); | ||
| 121 | +// //好邻居便利店 | ||
| 122 | + importLatLngs.add(new LatLng(39.933736, 116.312365)); | ||
| 123 | + | ||
| 124 | +// searchRouteResult(new LatLng(39.934266, 116.309228), new LatLng(39.939756, 116.319766), 0); | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + //根据几个关键点进行步行路径规划 | ||
| 128 | +// if (importLatLngs != null) { | ||
| 129 | +// if (importLatLngs.size() >= 1) { | ||
| 130 | +// for (int index = 0; index < importLatLngs.size(); index++) { | ||
| 131 | +// //开始分段规划路径 | ||
| 132 | +// //第一个点 | ||
| 133 | +// if (index == 0) { | ||
| 134 | +// searchRouteResult(startLatLng, importLatLngs.get(index), 0); | ||
| 135 | +// } else { | ||
| 136 | +// searchRouteResult(importLatLngs.get(index - 1), importLatLngs.get(index), index); | ||
| 137 | +// } | ||
| 138 | +// } | ||
| 139 | +// } else { | ||
| 140 | +// } | ||
| 141 | +// } | ||
| 79 | //设置底部卡片第一次可滑动的位置 | 142 | //设置底部卡片第一次可滑动的位置 |
| 80 | fragment.binding.slidingLayout.setAnchorPoint(0.6f); | 143 | fragment.binding.slidingLayout.setAnchorPoint(0.6f); |
| 81 | //设置底部卡片初始位置 | 144 | //设置底部卡片初始位置 |
| @@ -164,6 +227,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -164,6 +227,9 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 164 | if (baiduMap == null) { | 227 | if (baiduMap == null) { |
| 165 | baiduMap = mMapView.getMap(); | 228 | baiduMap = mMapView.getMap(); |
| 166 | } | 229 | } |
| 230 | + if (routePlanSearch == null) { | ||
| 231 | + routePlanSearch = RoutePlanSearch.newInstance(); | ||
| 232 | + } | ||
| 167 | if (mUiSettings == null) { | 233 | if (mUiSettings == null) { |
| 168 | mUiSettings = baiduMap.getUiSettings(); | 234 | mUiSettings = baiduMap.getUiSettings(); |
| 169 | } | 235 | } |
| @@ -200,6 +266,193 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -200,6 +266,193 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 200 | mLocClient.start(); | 266 | mLocClient.start(); |
| 201 | } | 267 | } |
| 202 | 268 | ||
| 269 | + /** | ||
| 270 | + * 开始路线规划 | ||
| 271 | + */ | ||
| 272 | + public void searchRouteResult(LatLng StartPoint, LatLng EndPoint, int index) { | ||
| 273 | + Log.e(TAG, "searchRouteResult: "); | ||
| 274 | + float currentZoom = baiduMap.getMapStatus().zoom; | ||
| 275 | + // 设置起终点信息,对于tranist search 来说,城市名无意义 | ||
| 276 | + PlanNode stNode = PlanNode.withLocation(StartPoint); | ||
| 277 | + PlanNode enNode = PlanNode.withLocation(EndPoint); | ||
| 278 | + routePlanSearch.setOnGetRoutePlanResultListener(new OnGetRoutePlanResultListener() { | ||
| 279 | + @Override | ||
| 280 | + public void onGetWalkingRouteResult(WalkingRouteResult walkingRouteResult) { | ||
| 281 | + Log.e(TAG, "onGetWalkingRouteResult: "); | ||
| 282 | + if (fragment.getActivity() == null) { | ||
| 283 | + return; | ||
| 284 | + } | ||
| 285 | + if (walkingRouteResult == null || walkingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) { | ||
| 286 | + Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show(); | ||
| 287 | + } | ||
| 288 | + if (walkingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) { | ||
| 289 | + // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息 | ||
| 290 | + return; | ||
| 291 | + } | ||
| 292 | + List<LatLng> points = new ArrayList<LatLng>(); | ||
| 293 | + if (walkingRouteResult.getRouteLines() != null) { | ||
| 294 | + if (walkingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) { | ||
| 295 | + //添加起点坐标 | ||
| 296 | +// points.add(StartPoint); | ||
| 297 | + for (int i = 0; i < walkingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) { | ||
| 298 | + for (int j = 0; j < walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) { | ||
| 299 | + points.add(walkingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j)); | ||
| 300 | + } | ||
| 301 | + } | ||
| 302 | + } | ||
| 303 | + //添加终点坐标 | ||
| 304 | +// if (endLatLng != null) { | ||
| 305 | +// points.add(endLatLng); | ||
| 306 | +// } | ||
| 307 | + | ||
| 308 | + ArrayList<Integer> traffics = new ArrayList<Integer>(); | ||
| 309 | + for (int i = 0; i < points.size(); i++) { | ||
| 310 | + if (i % 2 == 0) { | ||
| 311 | + traffics.add(i); | ||
| 312 | + } | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + | ||
| 316 | + if (points.size() > 0) { | ||
| 317 | +// if (baiduMap != null) { | ||
| 318 | +// baiduMap.clear(); | ||
| 319 | +// if (endLatLng != null) { | ||
| 320 | +// markPoi(endLatLng.latitude, endLatLng.longitude); | ||
| 321 | +// } | ||
| 322 | +// } | ||
| 323 | + | ||
| 324 | + //设置折线的属性 | ||
| 325 | +// OverlayOptions mOverlayOptions = new PolylineOptions() | ||
| 326 | +// .width(10) | ||
| 327 | +// .color(0xAAFF0000) | ||
| 328 | +// .points(points); | ||
| 329 | + //设置折线的属性 | ||
| 330 | + OverlayOptions mOverlayOptions = new PolylineOptions() | ||
| 331 | + .width(10) | ||
| 332 | + .dottedLine(true) | ||
| 333 | + .points(points) | ||
| 334 | + .customTextureList(getCustomTextureList()) | ||
| 335 | + .textureIndex(traffics);//设置纹理列表 | ||
| 336 | + //在地图上绘制折线 | ||
| 337 | + //mPloyline 折线对象 | ||
| 338 | + Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions); | ||
| 339 | + MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 340 | + builder.zoom(currentZoom); | ||
| 341 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | ||
| 342 | + | ||
| 343 | + } | ||
| 344 | + } | ||
| 345 | + } | ||
| 346 | + | ||
| 347 | + @Override | ||
| 348 | + public void onGetTransitRouteResult(TransitRouteResult transitRouteResult) { | ||
| 349 | + | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + @Override | ||
| 353 | + public void onGetMassTransitRouteResult(MassTransitRouteResult massTransitRouteResult) { | ||
| 354 | + | ||
| 355 | + } | ||
| 356 | + | ||
| 357 | + @Override | ||
| 358 | + public void onGetDrivingRouteResult(DrivingRouteResult drivingRouteResult) { | ||
| 359 | + if (fragment.getActivity() == null) { | ||
| 360 | + return; | ||
| 361 | + } | ||
| 362 | + | ||
| 363 | + if (drivingRouteResult == null || drivingRouteResult.error != SearchResult.ERRORNO.NO_ERROR) { | ||
| 364 | + Toast.makeText(fragment.getActivity(), "抱歉,无法获取路线!", Toast.LENGTH_SHORT).show(); | ||
| 365 | + } | ||
| 366 | + if (drivingRouteResult.error == SearchResult.ERRORNO.AMBIGUOUS_ROURE_ADDR) { | ||
| 367 | + // 起终点或途经点地址有岐义,通过以下接口获取建议查询信息 | ||
| 368 | + return; | ||
| 369 | + } | ||
| 370 | + List<LatLng> points = new ArrayList<LatLng>(); | ||
| 371 | + if (drivingRouteResult.getRouteLines() != null) { | ||
| 372 | + if (drivingRouteResult.getRouteLines().get(0).getAllStep().get(0).getWayPoints().size() > 0) { | ||
| 373 | + //添加起点坐标 | ||
| 374 | + if (mylocation != null) { | ||
| 375 | + points.add(new LatLng(mylocation.latitude, mylocation.longitude)); | ||
| 376 | + } | ||
| 377 | + for (int i = 0; i < drivingRouteResult.getRouteLines().get(0).getAllStep().size(); i++) { | ||
| 378 | + for (int j = 0; j < drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().size(); j++) { | ||
| 379 | + points.add(drivingRouteResult.getRouteLines().get(0).getAllStep().get(i).getWayPoints().get(j)); | ||
| 380 | + } | ||
| 381 | + } | ||
| 382 | + } | ||
| 383 | + //添加终点坐标 | ||
| 384 | + if (endLatLng != null) { | ||
| 385 | + points.add(endLatLng); | ||
| 386 | + } | ||
| 387 | + if (points.size() > 0) { | ||
| 388 | + if (baiduMap != null) { | ||
| 389 | + baiduMap.clear(); | ||
| 390 | + if (endLatLng != null) { | ||
| 391 | + markPoi(endLatLng.latitude, endLatLng.longitude); | ||
| 392 | + } | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + //设置折线的属性 | ||
| 396 | + OverlayOptions mOverlayOptions = new PolylineOptions() | ||
| 397 | + .width(10) | ||
| 398 | + .color(0xAAFF0000) | ||
| 399 | + .points(points); | ||
| 400 | + //在地图上绘制折线 | ||
| 401 | + //mPloyline 折线对象 | ||
| 402 | + Overlay mPolyline = baiduMap.addOverlay(mOverlayOptions); | ||
| 403 | + MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 404 | + builder.zoom(currentZoom); | ||
| 405 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | ||
| 406 | + | ||
| 407 | + } | ||
| 408 | + } | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + @Override | ||
| 412 | + public void onGetIndoorRouteResult(IndoorRouteResult indoorRouteResult) { | ||
| 413 | + | ||
| 414 | + } | ||
| 415 | + | ||
| 416 | + @Override | ||
| 417 | + public void onGetBikingRouteResult(BikingRouteResult bikingRouteResult) { | ||
| 418 | + | ||
| 419 | + } | ||
| 420 | + }); | ||
| 421 | + //开始检索 | ||
| 422 | +// routePlanSearch.drivingSearch((new DrivingRoutePlanOption()) | ||
| 423 | +// .from(stNode).to(enNode).policy(DrivingRoutePlanOption.DrivingPolicy.ECAR_DIS_FIRST) | ||
| 424 | +// .trafficPolicy(DrivingRoutePlanOption.DrivingTrafficPolicy.ROUTE_PATH_AND_TRAFFIC)); | ||
| 425 | + | ||
| 426 | + //开始步行检索 | ||
| 427 | + routePlanSearch.walkingSearch((new WalkingRoutePlanOption()) | ||
| 428 | + .from(stNode) | ||
| 429 | + .to(enNode)); | ||
| 430 | + } | ||
| 431 | +// showProgressDialog(); | ||
| 432 | + | ||
| 433 | + /** | ||
| 434 | + * 设置终点标记 | ||
| 435 | + * | ||
| 436 | + * @param Latitude | ||
| 437 | + * @param Longitude | ||
| 438 | + */ | ||
| 439 | + public void markPoi(double Latitude, double Longitude) { | ||
| 440 | + if (fragment.getActivity() == null) { | ||
| 441 | + return; | ||
| 442 | + } | ||
| 443 | + baiduMap.clear(); | ||
| 444 | + currentMark = null; | ||
| 445 | + LatLng ll = new LatLng(Latitude, Longitude); | ||
| 446 | + //设置坐标 | ||
| 447 | + //显示当前位置图标 | ||
| 448 | + Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(fragment.getActivity(), BitmapFactory.decodeResource(fragment.getActivity().getResources(), R.drawable.run_map_icon_end), 22, 32); | ||
| 449 | + currentMark = new MarkerOptions().position(ll).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | ||
| 450 | + baiduMap.addOverlay(currentMark); | ||
| 451 | + MapStatus.Builder builder = new MapStatus.Builder(); | ||
| 452 | + builder.target(ll).zoom(16.0f); | ||
| 453 | + baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | ||
| 454 | + } | ||
| 455 | + | ||
| 203 | @Override | 456 | @Override |
| 204 | public void onSensorChanged(SensorEvent sensorEvent) { | 457 | public void onSensorChanged(SensorEvent sensorEvent) { |
| 205 | double x = sensorEvent.values[SensorManager.DATA_X]; | 458 | double x = sensorEvent.values[SensorManager.DATA_X]; |
| @@ -222,6 +475,21 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -222,6 +475,21 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 222 | 475 | ||
| 223 | } | 476 | } |
| 224 | 477 | ||
| 478 | + /** | ||
| 479 | + * 纹理图片 | ||
| 480 | + * | ||
| 481 | + * @return | ||
| 482 | + */ | ||
| 483 | + public List<BitmapDescriptor> getCustomTextureList() { | ||
| 484 | + ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>(); | ||
| 485 | + list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png")); | ||
| 486 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png")); | ||
| 487 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png")); | ||
| 488 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png")); | ||
| 489 | +// list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png")); | ||
| 490 | + return list; | ||
| 491 | + } | ||
| 492 | + | ||
| 225 | public void onResume() { | 493 | public void onResume() { |
| 226 | if (mMapView != null) { | 494 | if (mMapView != null) { |
| 227 | mMapView.onResume(); | 495 | mMapView.onResume(); |
| @@ -277,11 +545,28 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | @@ -277,11 +545,28 @@ public class RunRaceDetailFragmentView implements MvpView, SensorEventListener { | ||
| 277 | baiduMap.setMyLocationData(mylocation); | 545 | baiduMap.setMyLocationData(mylocation); |
| 278 | builder.target(firstLatLng).zoom(DEFULT_ZOOM); | 546 | builder.target(firstLatLng).zoom(DEFULT_ZOOM); |
| 279 | baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); | 547 | baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); |
| 548 | + | ||
| 280 | // //显示当前位置图标 | 549 | // //显示当前位置图标 |
| 281 | // Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40); | 550 | // Bitmap pointBitmap = BitmapUtil.getBitmapFromDp(getContext(), BitmapFactory.decodeResource(getContext().getResources(), R.drawable.rt_ic_location), 40, 40); |
| 282 | // currentMark = new MarkerOptions().position(firstLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); | 551 | // currentMark = new MarkerOptions().position(firstLatLng).icon(BitmapDescriptorFactory.fromBitmap(pointBitmap)); |
| 283 | // baiduMap.addOverlay(currentMark); | 552 | // baiduMap.addOverlay(currentMark); |
| 284 | 553 | ||
| 554 | + //根据几个关键点进行步行路径规划 | ||
| 555 | + if (importLatLngs != null) { | ||
| 556 | + if (importLatLngs.size() >= 1) { | ||
| 557 | + for (int index = 0; index < importLatLngs.size(); index++) { | ||
| 558 | + //开始分段规划路径 | ||
| 559 | + //第一个点 | ||
| 560 | + if (index == 0) { | ||
| 561 | + searchRouteResult(startLatLng, importLatLngs.get(index), 0); | ||
| 562 | + } else { | ||
| 563 | + searchRouteResult(importLatLngs.get(index - 1), importLatLngs.get(index), index); | ||
| 564 | + } | ||
| 565 | + } | ||
| 566 | + } else { | ||
| 567 | + searchRouteResult(startLatLng, endLatLng, 0); | ||
| 568 | + } | ||
| 569 | + } | ||
| 285 | 570 | ||
| 286 | } | 571 | } |
| 287 | } | 572 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/PedometerMainActivity.java
| @@ -50,12 +50,6 @@ public class PedometerMainActivity extends QMUIFragmentActivity { | @@ -50,12 +50,6 @@ public class PedometerMainActivity extends QMUIFragmentActivity { | ||
| 50 | protected void onCreate(Bundle savedInstanceState) { | 50 | protected void onCreate(Bundle savedInstanceState) { |
| 51 | super.onCreate(savedInstanceState); | 51 | super.onCreate(savedInstanceState); |
| 52 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | 52 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); |
| 53 | - | ||
| 54 | - //在使用SDK各组件之前初始化context信息,传入ApplicationContext | ||
| 55 | - SDKInitializer.initialize(getApplicationContext()); | ||
| 56 | - //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型. | ||
| 57 | - //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。 | ||
| 58 | - SDKInitializer.setCoordType(CoordType.GCJ02); | ||
| 59 | // setContentView(R.layout.activity_pedometer_main); | 53 | // setContentView(R.layout.activity_pedometer_main); |
| 60 | getPermissionsWithTip(); | 54 | getPermissionsWithTip(); |
| 61 | } | 55 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunRaceDetailActivity.java
| @@ -41,11 +41,6 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { | @@ -41,11 +41,6 @@ public class RunRaceDetailActivity extends QMUIFragmentActivity { | ||
| 41 | protected void onCreate(Bundle savedInstanceState) { | 41 | protected void onCreate(Bundle savedInstanceState) { |
| 42 | super.onCreate(savedInstanceState); | 42 | super.onCreate(savedInstanceState); |
| 43 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | 43 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); |
| 44 | - //在使用SDK各组件之前初始化context信息,传入ApplicationContext | ||
| 45 | - SDKInitializer.initialize(getApplicationContext()); | ||
| 46 | - //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型. | ||
| 47 | - //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。 | ||
| 48 | - SDKInitializer.setCoordType(CoordType.GCJ02); | ||
| 49 | addFragment(); | 44 | addFragment(); |
| 50 | 45 | ||
| 51 | } | 46 | } |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/activity/RunningMapActivity.java
| @@ -25,11 +25,7 @@ public class RunningMapActivity extends QMUIFragmentActivity { | @@ -25,11 +25,7 @@ public class RunningMapActivity extends QMUIFragmentActivity { | ||
| 25 | @Override | 25 | @Override |
| 26 | protected void onCreate(Bundle savedInstanceState) { | 26 | protected void onCreate(Bundle savedInstanceState) { |
| 27 | super.onCreate(savedInstanceState); | 27 | super.onCreate(savedInstanceState); |
| 28 | - //在使用SDK各组件之前初始化context信息,传入ApplicationContext | ||
| 29 | - SDKInitializer.initialize(getApplicationContext()); | ||
| 30 | - //自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型. | ||
| 31 | - //包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。 | ||
| 32 | - SDKInitializer.setCoordType(CoordType.GCJ02); | 28 | + |
| 33 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); | 29 | StatusBarUtil2.setColor(this, getResources().getColor(R.color.run_main_bg), 0); |
| 34 | RunningMapBean chronometerBean = (RunningMapBean) getIntent().getExtras().getSerializable("runningMapBean"); | 30 | RunningMapBean chronometerBean = (RunningMapBean) getIntent().getExtras().getSerializable("runningMapBean"); |
| 35 | if (chronometerBean != null) { | 31 | if (chronometerBean != null) { |
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/ui/widget/FivePersonIconView.java
| @@ -109,7 +109,7 @@ public class FivePersonIconView extends LinearLayout { | @@ -109,7 +109,7 @@ public class FivePersonIconView extends LinearLayout { | ||
| 109 | if (index == 1) { | 109 | if (index == 1) { |
| 110 | //需要进一步缩放的距离(默认10dp) | 110 | //需要进一步缩放的距离(默认10dp) |
| 111 | int needMargin = dip2px(context, DEFAULT_LEFT_MARGIN); | 111 | int needMargin = dip2px(context, DEFAULT_LEFT_MARGIN); |
| 112 | - Log.e(TAG, "onMeasure:"); | 112 | +// Log.e(TAG, "onMeasure:"); |
| 113 | //根据xml中我们编码时给的宽和高,动态设置这5个图标的距离 | 113 | //根据xml中我们编码时给的宽和高,动态设置这5个图标的距离 |
| 114 | //计算不进行左侧缩进时,总体宽度 | 114 | //计算不进行左侧缩进时,总体宽度 |
| 115 | int noMargin = 0; | 115 | int noMargin = 0; |
| @@ -128,18 +128,18 @@ public class FivePersonIconView extends LinearLayout { | @@ -128,18 +128,18 @@ public class FivePersonIconView extends LinearLayout { | ||
| 128 | //获取当前用户设定的总长度 | 128 | //获取当前用户设定的总长度 |
| 129 | int userSetViewWidth = getMeasuredWidth(); | 129 | int userSetViewWidth = getMeasuredWidth(); |
| 130 | 130 | ||
| 131 | - Log.e(TAG + index, "noMargin: " + noMargin + ",userSetViewWidth:" + userSetViewWidth); | 131 | +// Log.e(TAG + index, "noMargin: " + noMargin + ",userSetViewWidth:" + userSetViewWidth); |
| 132 | //判断是否需要进一步缩放 | 132 | //判断是否需要进一步缩放 |
| 133 | if (noMargin > userSetViewWidth) { | 133 | if (noMargin > userSetViewWidth) { |
| 134 | int leftMargin = noMargin - userSetViewWidth; | 134 | int leftMargin = noMargin - userSetViewWidth; |
| 135 | //平分需要设置的间隔 | 135 | //平分需要设置的间隔 |
| 136 | needMargin = leftMargin / (MAX_ICON - 1); | 136 | needMargin = leftMargin / (MAX_ICON - 1); |
| 137 | - Log.e(TAG, "onMeasure: 平分后" + needMargin); | 137 | +// Log.e(TAG, "onMeasure: 平分后" + needMargin); |
| 138 | if (needMargin <= dip2px(context, DEFAULT_LEFT_MARGIN)) { | 138 | if (needMargin <= dip2px(context, DEFAULT_LEFT_MARGIN)) { |
| 139 | needMargin = dip2px(context, DEFAULT_LEFT_MARGIN); | 139 | needMargin = dip2px(context, DEFAULT_LEFT_MARGIN); |
| 140 | } | 140 | } |
| 141 | } else { | 141 | } else { |
| 142 | - Log.e(TAG, "onMeasure: 不平分" + needMargin); | 142 | +// Log.e(TAG, "onMeasure: 不平分" + needMargin); |
| 143 | needMargin = dip2px(context, DEFAULT_LEFT_MARGIN); | 143 | needMargin = dip2px(context, DEFAULT_LEFT_MARGIN); |
| 144 | } | 144 | } |
| 145 | 145 |
moudle_pedometer/src/main/res/drawable-hdpi/run_map_icon_end.png
0 → 100644
1.6 KB
moudle_pedometer/src/main/res/drawable-hdpi/run_map_icon_start.png
0 → 100644
1.7 KB