Complete small map draw polyline
This commit is contained in:
@@ -4,12 +4,14 @@ import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.thread.CancelableCountDownLatch;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
@@ -23,6 +25,7 @@ import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.maps.model.PolylineOptions;
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -36,6 +39,8 @@ import com.mogo.utils.logger.Logger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ch.hsr.geohash.GeoHash;
|
||||
|
||||
/**
|
||||
* 小地图的方向View
|
||||
*
|
||||
@@ -178,13 +183,33 @@ public class SmallMapDirectionView
|
||||
mCarMarker.setToTop();
|
||||
}
|
||||
|
||||
|
||||
if (mCoordinatesLatLng.size() > 1) {
|
||||
mCoordinatesLatLngCurrent.clear();
|
||||
for (LatLng lng : mCoordinatesLatLng) {
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(lng.latitude, lng.longitude);
|
||||
mCoordinatesLatLngCurrent.add(mogoLatLng);
|
||||
}
|
||||
drawablePolyline(mCoordinatesLatLngCurrent);
|
||||
|
||||
// 结束位置
|
||||
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));
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.adas.IMogoAdasRouteCallBack;
|
||||
import com.mogo.service.smp.IMogoSmallMapProvider;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -21,7 +22,7 @@ import java.util.List;
|
||||
* @date 12/10/20 1:34 PM
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_SMALL_MAP)
|
||||
public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener {
|
||||
public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChangedListener, IMogoAdasRouteCallBack {
|
||||
private final String TAG = "SmallVisionProvider";
|
||||
|
||||
private Context mContext;
|
||||
@@ -36,6 +37,7 @@ public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChang
|
||||
mActivity = activity;
|
||||
mContainerId = containerId;
|
||||
SmpServiceManager.init(mActivity);
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().addAdasAutopilotRouteCallBack(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,4 +110,13 @@ public class SmallMapProvider implements IMogoSmallMapProvider, IMogoStatusChang
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void routeResult(List<MogoLatLng> routeList) {
|
||||
if (routeList != null && routeList.size() > 0) {
|
||||
drawablePolyline(routeList);
|
||||
} else {
|
||||
clearPolyline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user