From 6bc17d181b0d0d057875bbffe233998d71182fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E5=AE=8F=E5=AE=87?= Date: Fri, 21 Feb 2020 22:21:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86bug=20=E3=80=90?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E8=BD=A6=E8=BE=86=E3=80=91=E6=AF=8F=E6=AC=A1?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=EF=BC=8C=E5=9C=A8=E7=BA=BF=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E5=8D=A1=E7=89=87=E9=83=BD=E4=BC=9A=E9=80=89=E6=8B=A9=E4=B8=80?= =?UTF-8?q?=E8=BE=86=E8=BD=A6=E6=98=BE=E7=A4=BA=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E8=BF=99=E8=BE=86=E8=BD=A6=E6=A0=B9=E6=9C=AC=E4=B8=8D=E5=9C=A8?= =?UTF-8?q?=E5=91=A8=E8=BE=B9=EF=BC=8CACCON=E5=90=8E=E5=BA=94=E5=BD=93?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=98=BE=E7=A4=BA=E6=9F=90=E4=B8=80?= =?UTF-8?q?=E8=BD=A6=E8=BE=86=E7=9A=84=E5=9C=A8=E7=BA=BF=E8=BD=A6=E8=BE=86?= =?UTF-8?q?=E5=8D=A1=E7=89=87=EF=BC=8C=E6=88=96=E8=80=85=E9=80=89=E5=8F=96?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E8=BD=A6=E8=BE=86=E7=9A=84=E5=9C=A8=E7=BA=BF?= =?UTF-8?q?=E8=BD=A6=E8=BE=86=E5=8D=A1=E7=89=87=E4=B9=9F=E8=A1=8C=20http:/?= =?UTF-8?q?/jira.zhidaohulian.com/browse/UI-372=3Fjql=3Dproject%20%3D%20UI?= =?UTF-8?q?%20AND%20assignee%20in%20(donghongyu)%20ORDER%20BY%20priority%2?= =?UTF-8?q?0DESC%2C%20updated%20DESC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/service/MarkerServiceHandler.java | 2 +- .../service/marker/MapMarkerManager.java | 25 +++++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index fca2cc564e..c5b640fc98 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -56,7 +56,7 @@ public class MarkerServiceHandler { mMarkerManager = mMapService.getMarkerManager(context); mNavi = mMapService.getNavi(context); mMapUIController = mMapService.getMapUIController(); - mLocationClient = mMapService.getLocationClient(context); + mLocationClient = mMapService.getSingletonLocationClient(context); mMapMarkerManager = MapMarkerManager.getInstance(context); mMapMarkerManager.init(context); diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java index 40d3d632c4..2dc8d3121c 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java @@ -15,6 +15,7 @@ import com.amap.api.maps.model.animation.Animation; import com.amap.api.maps.model.animation.ScaleAnimation; import com.mogo.map.MogoLatLng; import com.mogo.map.impl.amap.marker.AMapMarkerWrapper; +import com.mogo.map.location.MogoLocation; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.IMogoMarkerClickListener; import com.mogo.map.marker.MogoMarkerOptions; @@ -387,7 +388,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag noveltyInfoList = markerCardResult.getNoveltyInfo(); } if (onlineCarList != null) { - double nearlyDistance = Double.MAX_VALUE; + double nearlyDistance = Float.MAX_VALUE; for (MarkerOnlineCar markerOnlineCar : onlineCarList) { MarkerLocation markerLocation = markerOnlineCar.getLocation(); @@ -401,16 +402,25 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag IMogoMarker iMogoMarker = drawMapMarker(markerShowEntity); // 计算在线车辆距离当前车辆的距离,每次都与最后一次距离最近的进行比较,保留距离最近的车辆,进行卡片展示 try { - double calculateDistance = Utils.calculateLineDistance( - new MogoLatLng(markerLocation.getLat(), markerLocation.getLat()), - new MogoLatLng( - MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLatitude(), - MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getLongitude() - ) + // 当前车辆的位置 + MogoLocation currentLocation = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation(); + + // 计算车辆距离指定气泡的距离 + float calculateDistance = Utils.calculateLineDistance( + new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()), + new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude()) ); +// Logger.d("点之间距离", +// "当前车辆经纬度:" + +// "\n\tlatitude=" + currentLocation.getLatitude() + +// "\n\tlongitude=" + currentLocation.getLongitude() + +// "\n气泡经纬度:" + markerLocation + +// "\n相距:" + calculateDistance + "米"); + // 进行比较,保留最近的一个数据 if (calculateDistance < nearlyDistance) { + nearlyDistance = calculateDistance; nearlyMogoMarker = iMogoMarker; } @@ -418,6 +428,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, IMogoOnMessag e.printStackTrace(); } } + Logger.d("点之间距离", "距离当前车辆位置最近的距离为:" + nearlyDistance); fillNumberTrackEventBody(array, 3, onlineCarList.size()); }