[MAP] 高精地图Marker绘制逻辑重构
This commit is contained in:
@@ -7,9 +7,8 @@ import android.view.View;
|
||||
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
@@ -33,7 +32,7 @@ import mogo.yycp.api.proto.SocketDownData;
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
|
||||
public static MarkerOptions fromMogo(MogoMarkerOptions opt) {
|
||||
public static MarkerOptions fromMogo(Point.Options opt) {
|
||||
|
||||
if (opt == null) {
|
||||
return null;
|
||||
@@ -59,25 +58,26 @@ public class ObjectUtils {
|
||||
.rotateAngle(opt.getRotate())
|
||||
.setFlat(opt.isFlat())
|
||||
.visible(opt.isVisible())
|
||||
.infoWindowEnable(opt.isInifoWindowEnable())
|
||||
.infoWindowEnable(opt.isInfoWindowEnable())
|
||||
.scale(opt.getScale())
|
||||
.alpha(opt.getAlpha())
|
||||
.setInfoWindowOffset(opt.getOffsetX(), opt.getOffsetY())
|
||||
.zIndex(opt.getzIndex());
|
||||
.zIndex(opt.getLevel().getZIndex());
|
||||
|
||||
try {
|
||||
if (!TextUtils.isEmpty(opt.getAnchorColor())) {
|
||||
Color.parseColor(opt.getAnchorColor());
|
||||
markerOptions.anchorColor(opt.getAnchorColor());
|
||||
String anchorColor = opt.getAnchorColor();
|
||||
if (anchorColor != null && !TextUtils.isEmpty(anchorColor)) {
|
||||
Color.parseColor(anchorColor);
|
||||
markerOptions.anchorColor(anchorColor);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
}
|
||||
markerOptions.vrEnable(opt.is3DMode());
|
||||
if (!TextUtils.isEmpty(opt.getResName())) {
|
||||
markerOptions.setMarkerIconName(opt.getResName());
|
||||
String resName = opt.getResName();
|
||||
if (resName != null && !TextUtils.isEmpty(resName)) {
|
||||
markerOptions.setMarkerIconName(resName);
|
||||
} else {
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt);
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo(opt.getIcon(), opt.getIconView());
|
||||
if (descriptor != null) {
|
||||
markerOptions.markerIcon(descriptor);
|
||||
}
|
||||
@@ -85,11 +85,13 @@ public class ObjectUtils {
|
||||
markerOptions.marker3DIcon(opt.getIcon3DRes());
|
||||
}
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getTitle())) {
|
||||
markerOptions.title(opt.getTitle());
|
||||
String title = opt.getTitle();
|
||||
if (title != null && !TextUtils.isEmpty(title)) {
|
||||
markerOptions.title(title);
|
||||
}
|
||||
if (!TextUtils.isEmpty(opt.getSnippet())) {
|
||||
markerOptions.snippet(opt.getSnippet());
|
||||
String snippet = opt.getSnippet();
|
||||
if (snippet != null && !TextUtils.isEmpty(snippet)) {
|
||||
markerOptions.snippet(snippet);
|
||||
}
|
||||
return markerOptions;
|
||||
}
|
||||
@@ -107,7 +109,8 @@ public class ObjectUtils {
|
||||
markerOptions.setLat(trafficData.getLatitude());
|
||||
markerOptions.setLon(trafficData.getLongitude());
|
||||
markerOptions.setTime(Double.valueOf(trafficData.getSatelliteTime() * 1000).longValue());
|
||||
if(trafficData.getColor()!=null && !trafficData.getColor().isEmpty()){
|
||||
trafficData.getColor();
|
||||
if(!trafficData.getColor().isEmpty()){
|
||||
markerOptions.setColor(trafficData.getColor());
|
||||
}else{
|
||||
markerOptions.setColor("#00000000");
|
||||
@@ -138,68 +141,16 @@ public class ObjectUtils {
|
||||
return markerOptions;
|
||||
}
|
||||
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(MogoMarkerOptions options) {
|
||||
if (options == null) {
|
||||
return null;
|
||||
}
|
||||
Bitmap icon = options.getIcon();
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(Bitmap icon, View view) {
|
||||
if (icon != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromBitmap(icon);
|
||||
}
|
||||
View view = options.getIconView();
|
||||
if (view != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromView(view);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static MogoLocation fromLocation(com.zhidaoauto.map.sdk.open.location.MogoLocation aLocation) {
|
||||
if (aLocation == null) {
|
||||
return null;
|
||||
}
|
||||
MogoLocation location = new MogoLocation();
|
||||
|
||||
//agps 高德
|
||||
//agps_rtk 高德-高精
|
||||
if (aLocation.getProvider().isEmpty()) {
|
||||
location.setLocType(0);
|
||||
}
|
||||
if ("AGPS".equals(aLocation.getProvider())) {
|
||||
location.setLocType(1); // 定位类型为高德坐标(网路或者硬件定位)
|
||||
} else if ("AGPS_RTK".equals(aLocation.getProvider())) {
|
||||
location.setLocType(1000); // 定位类型为WGS84进行转译的坐标
|
||||
} else {
|
||||
location.setLocType(0);
|
||||
}
|
||||
location.setSatellite(4);
|
||||
location.setGnssSpeed(aLocation.getSpeed());
|
||||
location.setLatitude(aLocation.getLat());
|
||||
location.setLongitude(aLocation.getLon());
|
||||
location.setAltitude(aLocation.getAltitude());
|
||||
location.setHeading((float) aLocation.getHeading());
|
||||
location.setCityCode(aLocation.getCityCode());
|
||||
location.setCityName(aLocation.getCity());
|
||||
location.setProvider(aLocation.getProvider());
|
||||
location.setAddress(aLocation.getAddress());
|
||||
location.setDistrict(aLocation.getDistrict());
|
||||
location.setProvince(aLocation.getProvince());
|
||||
location.setAdCode(aLocation.getAdCode());
|
||||
// location.setAccuracy( aLocation.getAccuracy() );
|
||||
// location.setTime( aLocation.getTime() );
|
||||
// location.setLocationDetail( aLocation.getLocationDetail() );
|
||||
// location.setPoiName( aLocation.getPoiName() );
|
||||
// location.setAoiName( aLocation.getAoiName() );
|
||||
// location.setErrCode( aLocation.getErrorCode() );
|
||||
// location.setErrInfo( aLocation.getErrorInfo() );
|
||||
// location.setStreetNum( aLocation.getStreetNum() );
|
||||
// location.setDescription( aLocation.getDescription() );
|
||||
// location.setBuildingId( aLocation.getBuildingId() );
|
||||
// location.setFloor( aLocation.getFloor() );
|
||||
// location.setGpsAccuracyStatus( aLocation.getGpsAccuracyStatus() );
|
||||
return location;
|
||||
}
|
||||
|
||||
public static LonLatPoint fromMogo(MogoLatLng latLng) {
|
||||
if (latLng == null) {
|
||||
return null;
|
||||
@@ -214,12 +165,12 @@ public class ObjectUtils {
|
||||
return new MogoLatLng(point.getLatitude(), point.getLongitude());
|
||||
}
|
||||
|
||||
public static PolylineOptions fromMogo(MogoPolylineOptions options) {
|
||||
public static PolylineOptions fromMogo(Polyline.Options options) {
|
||||
if (options == null) {
|
||||
return null;
|
||||
}
|
||||
PolylineOptions target = new PolylineOptions();
|
||||
target.setGps(options.gps());
|
||||
target.setGps(options.isUseGps());
|
||||
if (options.getPoints() != null) {
|
||||
List<LonLatPoint> points = new ArrayList<>();
|
||||
for (MogoLatLng point : options.getPoints()) {
|
||||
@@ -228,20 +179,24 @@ public class ObjectUtils {
|
||||
target.lonLatPoints(points);
|
||||
}
|
||||
target.setLineWidth(options.getWidth());
|
||||
target.zIndex(options.getZIndex());
|
||||
target.dottedLine(options.isDottedLine());
|
||||
target.geodesic(options.isGeodesic());
|
||||
target.dottedLineType(options.getDottedLineType());
|
||||
target.zIndex(options.getLevel().getZIndex());
|
||||
target.setColor(options.getColor());
|
||||
target.useGradient(options.isGradient());
|
||||
target.useFacade(options.useFacade);
|
||||
if (options.maxIndex >= 0f) {
|
||||
target.maxIndex = options.maxIndex;
|
||||
target.useFacade(options.getUseFacade());
|
||||
target.setVisible(options.isVisible());
|
||||
if (options.getMaxIndex() >= 0f) {
|
||||
target.maxIndex = options.getMaxIndex();
|
||||
}
|
||||
if (options.getColorValues() != null) {
|
||||
target.colorValues(options.getColorValues());
|
||||
if (options.getColors() != null) {
|
||||
target.colorValues(options.getColors());
|
||||
}
|
||||
if (options.isBrightOn()) {
|
||||
if (options.isLightOn()) {
|
||||
target.isBright = true;
|
||||
target.brightColor = options.getBrightColor();
|
||||
target.brightSpeed = options.getBrightSpeed();
|
||||
target.brightColor = options.getLightColor();
|
||||
target.brightSpeed = options.getLightSpeed();
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user