[Update]同一个线程绘制和擦除

This commit is contained in:
chenfufeng
2022-08-04 17:55:33 +08:00
parent 076a9fbccb
commit 90f3fce68e

View File

@@ -41,6 +41,7 @@ import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.overview.InfStructureManager;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import org.jetbrains.annotations.NotNull;
@@ -232,18 +233,22 @@ public class AMapCustomView
// 转成高德坐标系并存储
MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext);
List<LatLng> planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints();
displayCustomOverView();
drawStartAndEndMarker(planningPointList);
UiThreadHandler.post(() -> {
displayCustomOverView();
drawStartAndEndMarker(planningPointList);
});
MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> {
// 每1s刷新一下轨迹线
if (points.size() > 0) {
drawPolyline(points, locIndex);
} else {
clearCustomPolyline();
}
UiThreadHandler.post(() -> {
if (points.size() > 0) {
drawPolyline(points, locIndex);
}
});
});
MarkerDrawerManager.INSTANCE.startLoopCalCarLocation();
drawInfrastructureMarkers(locationList);
UiThreadHandler.post(() -> {
drawInfrastructureMarkers(locationList);
});
}
@Override
@@ -264,11 +269,13 @@ public class AMapCustomView
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from) {
mLocation = location;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(location.getLongitude(), location.getLatitude()));
drawCarMarker(location);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
UiThreadHandler.post(() -> {
drawCarMarker(location);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
});
}
public void onCreateView(Bundle savedInstanceState) {