|
|
|
|
@@ -192,36 +192,36 @@ public class SmallMapDirectionView
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (mCoordinatesLatLng.size() > 1) {
|
|
|
|
|
// mCoordinatesLatLngCurrent.clear();
|
|
|
|
|
// for (LatLng lng : mCoordinatesLatLng) {
|
|
|
|
|
// MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
|
|
|
|
|
// mCoordinatesLatLngCurrent.add(mogoLatLng);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 结束位置
|
|
|
|
|
// LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
|
|
|
|
// // 与结束位置进行 GeoHash 0-12
|
|
|
|
|
//// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7);
|
|
|
|
|
//// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7);
|
|
|
|
|
//// Log.d(MODULE_NAME, "currentGeoHash=" + currentGeoHash);
|
|
|
|
|
//// Log.d(MODULE_NAME, "endGeoHash=" + endGeoHash);
|
|
|
|
|
//
|
|
|
|
|
// float calculateDistance = CoordinateUtils.calculateLineDistance(
|
|
|
|
|
// endLatLng.latitude, endLatLng.longitude,
|
|
|
|
|
// currentLatLng.latitude, currentLatLng.longitude
|
|
|
|
|
// );
|
|
|
|
|
//
|
|
|
|
|
// Log.d(MODULE_NAME, "calculateDistance=" + calculateDistance);
|
|
|
|
|
// if (calculateDistance <= 20) {
|
|
|
|
|
// clearPolyline();
|
|
|
|
|
// } else {
|
|
|
|
|
// drawablePolyline(mCoordinatesLatLngCurrent);
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// //设置希望展示的地图缩放级别
|
|
|
|
|
// mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
|
|
|
|
|
// }
|
|
|
|
|
if (mCoordinatesLatLng.size() > 1) {
|
|
|
|
|
mCoordinatesLatLngCurrent.clear();
|
|
|
|
|
for (LatLng lng : mCoordinatesLatLng) {
|
|
|
|
|
MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
|
|
|
|
|
mCoordinatesLatLngCurrent.add(mogoLatLng);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 结束位置
|
|
|
|
|
LatLng endLatLng = mCoordinatesLatLng.get(mCoordinatesLatLng.size() - 1);
|
|
|
|
|
// 与结束位置进行 GeoHash 0-12
|
|
|
|
|
// GeoHash endGeoHash = GeoHash.withCharacterPrecision(endLatLng.latitude, endLatLng.longitude, 7);
|
|
|
|
|
// GeoHash currentGeoHash = GeoHash.withCharacterPrecision(currentLatLng.latitude, currentLatLng.longitude, 7);
|
|
|
|
|
// Log.d(MODULE_NAME, "currentGeoHash=" + currentGeoHash);
|
|
|
|
|
// Log.d(MODULE_NAME, "endGeoHash=" + endGeoHash);
|
|
|
|
|
|
|
|
|
|
float calculateDistance = CoordinateUtils.calculateLineDistance(
|
|
|
|
|
endLatLng.latitude, endLatLng.longitude,
|
|
|
|
|
currentLatLng.latitude, currentLatLng.longitude
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Log.d(MODULE_NAME, "calculateDistance=" + calculateDistance);
|
|
|
|
|
if (calculateDistance <= 20) {
|
|
|
|
|
clearPolyline();
|
|
|
|
|
} else {
|
|
|
|
|
drawablePolyline();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//设置希望展示的地图缩放级别
|
|
|
|
|
mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLatLng, zoomLevel));
|
|
|
|
|
}
|
|
|
|
|
CameraPosition cameraPosition = new CameraPosition.Builder().target(mCarMarker.getPosition()).bearing(latLng.getBearing()).tilt(0).zoom(zoomLevel).build();
|
|
|
|
|
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
|
|
|
|
}
|
|
|
|
|
@@ -232,14 +232,14 @@ public class SmallMapDirectionView
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
|
|
|
|
public void drawablePolyline() {
|
|
|
|
|
clearPolyline();
|
|
|
|
|
// mCoordinatesLatLng.clear();
|
|
|
|
|
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext,coordinates);
|
|
|
|
|
mCoordinatesLatLng.addAll(latLngs);
|
|
|
|
|
// List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext,coordinates);
|
|
|
|
|
// mCoordinatesLatLng.addAll(latLngs);
|
|
|
|
|
// for (LatLng coordinate : mCoordinatesLatLng) {
|
|
|
|
|
//// mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon()));
|
|
|
|
|
//// Log.e("",coordinate.latitude+":"+coordinate.longitude);
|
|
|
|
|
// mCoordinatesLatLng.add(new LatLng(coordinate.getLat(), coordinate.getLon()));
|
|
|
|
|
// Log.e("",coordinate.latitude+":"+coordinate.longitude);
|
|
|
|
|
// }
|
|
|
|
|
if (mAMap != null) {
|
|
|
|
|
if (mCoordinatesLatLng.size() > 2) {
|
|
|
|
|
@@ -291,6 +291,19 @@ public class SmallMapDirectionView
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public void clearPolyline() {
|
|
|
|
|
// mCoordinatesLatLng.clear();
|
|
|
|
|
if (mPolyline != null) {
|
|
|
|
|
mPolyline.remove();
|
|
|
|
|
}
|
|
|
|
|
if (mStartMarker != null) {
|
|
|
|
|
mStartMarker.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
if (mEndMarker != null) {
|
|
|
|
|
mEndMarker.setVisible(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void resetPolyine(){
|
|
|
|
|
mCoordinatesLatLng.clear();
|
|
|
|
|
if (mPolyline != null) {
|
|
|
|
|
mPolyline.remove();
|
|
|
|
|
@@ -327,9 +340,9 @@ public class SmallMapDirectionView
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setRouteList(List<MogoLatLng> coordinates) {
|
|
|
|
|
// mCoordinatesLatLng.clear();
|
|
|
|
|
// List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext,coordinates);
|
|
|
|
|
// mCoordinatesLatLng.addAll(latLngs);
|
|
|
|
|
public void convert(List<MogoLatLng> coordinates) {
|
|
|
|
|
mCoordinatesLatLng.clear();
|
|
|
|
|
List<LatLng> latLngs = CoordinateConverterFrom84ForList(mContext,coordinates);
|
|
|
|
|
mCoordinatesLatLng.addAll(latLngs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|