对小地图缩减定位精度防止方向发生错乱
This commit is contained in:
@@ -32,6 +32,8 @@ import com.mogo.module.small.map.utils.MapAssetStyleUtils;
|
||||
import com.mogo.module.small.map.view.ISmallMapDirectionView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -147,7 +149,6 @@ public class SmallMapDirectionView
|
||||
mAMapNavi.setIsUseExtraGPSData(true);
|
||||
|
||||
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
@@ -249,6 +250,19 @@ public class SmallMapDirectionView
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
Logger.d(MODULE_NAME, "onCarLocationChanged2 latLng:" + latLng);
|
||||
if (mAMapNavi != null) {
|
||||
NumberFormat nf = NumberFormat.getNumberInstance();
|
||||
// 保留两位小数
|
||||
nf.setMaximumFractionDigits(6);
|
||||
// 如果不需要四舍五入,可以使用RoundingMode.DOWN
|
||||
nf.setRoundingMode(RoundingMode.UP);
|
||||
try {
|
||||
latLng.setLatitude(Double.valueOf(nf.format(latLng.getLatitude())));
|
||||
latLng.setLongitude(Double.valueOf(nf.format(latLng.getLongitude())));
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
latLng.setLatitude(latLng.getLatitude());
|
||||
latLng.setLongitude(latLng.getLongitude());
|
||||
}
|
||||
mAMapNavi.setExtraGPSData(2, latLng);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user