同步绘制小地图
This commit is contained in:
@@ -2,6 +2,7 @@ package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -72,6 +73,9 @@ class AdasRecognizedResultDrawer {
|
||||
}
|
||||
IMogoMarker marker = null;
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
if ( TextUtils.isEmpty( uniqueKey ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
marker = mAdasRecognizedMarkersCaches.get( uniqueKey );
|
||||
}
|
||||
@@ -81,17 +85,19 @@ class AdasRecognizedResultDrawer {
|
||||
}
|
||||
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
MogoLatLng endLatLon = null;
|
||||
if ( recognizedListResult.latLonList != null
|
||||
|| recognizedListResult.latLonList.size() > 1 ) {
|
||||
&& recognizedListResult.latLonList.size() > 1 ) {
|
||||
for ( int j = 0; j < recognizedListResult.latLonList.size(); j++ ) {
|
||||
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( j );
|
||||
if ( latLon == null ) {
|
||||
continue;
|
||||
}
|
||||
points.add( new MogoLatLng( latLon.lat, latLon.lon ) );
|
||||
points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) );
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if ( recognizedListResult.latLonList != null
|
||||
&& recognizedListResult.latLonList.size() == 1 ) {
|
||||
// 原来的点和新的点做一个数组进行平滑移动
|
||||
MogoLatLng latLng = marker.getPosition();
|
||||
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( 0 );
|
||||
@@ -99,7 +105,10 @@ class AdasRecognizedResultDrawer {
|
||||
continue;
|
||||
}
|
||||
points.add( latLng );
|
||||
points.add( new MogoLatLng( latLng.lat, latLon.lon ) );
|
||||
points.add( endLatLon = new MogoLatLng( latLng.lat, latLon.lon ) );
|
||||
}
|
||||
if ( endLatLon != null ) {
|
||||
marker.setPosition( endLatLon.lat, endLatLon.lon );
|
||||
}
|
||||
if ( points.size() >= 1 ) {
|
||||
marker.startSmooth( points, 1 );
|
||||
@@ -153,6 +162,7 @@ class AdasRecognizedResultDrawer {
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_ADAS )
|
||||
.gps( true )
|
||||
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) )
|
||||
.position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) );
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
|
||||
@@ -77,10 +77,12 @@ class MarkerDrawer {
|
||||
}
|
||||
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).addMarker( markerShowEntity.getMarkerType(), options );
|
||||
marker.setOwner( markerShowEntity.getMarkerType() );
|
||||
markerView.setMarker( marker );
|
||||
marker.setOnMarkerClickListener( listener );
|
||||
markerShowEntity.setMarker( marker );
|
||||
if ( marker != null ) {
|
||||
marker.setOwner( markerShowEntity.getMarkerType() );
|
||||
markerView.setMarker( marker );
|
||||
marker.setOnMarkerClickListener( listener );
|
||||
markerShowEntity.setMarker( marker );
|
||||
}
|
||||
return marker;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -15,6 +19,7 @@ import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -31,6 +36,8 @@ public
|
||||
*/
|
||||
class SnapshotSetDataDrawer {
|
||||
|
||||
private static final String TAG = "SnapshotSetDataDrawer";
|
||||
|
||||
private static volatile SnapshotSetDataDrawer sInstance;
|
||||
|
||||
private Context mContext;
|
||||
@@ -84,16 +91,23 @@ class SnapshotSetDataDrawer {
|
||||
}
|
||||
IMogoMarker marker = null;
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( TextUtils.isEmpty( uniqueKey ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
marker = mCloudSnapshotMarkersCaches.get( uniqueKey );
|
||||
}
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawSnapshotDataMarker( cloudRoadData );
|
||||
if ( marker == null ) {
|
||||
continue;
|
||||
}
|
||||
mCloudSnapshotMarkersCaches.put( uniqueKey, marker );
|
||||
}
|
||||
MogoLatLng endLatLon = null;
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
if ( cloudRoadData.getCoordinates() != null
|
||||
|| cloudRoadData.getCoordinates().size() > 1 ) {
|
||||
&& cloudRoadData.getCoordinates().size() > 1 ) {
|
||||
for ( int j = 0; j < cloudRoadData.getCoordinates().size(); j++ ) {
|
||||
CloudLocationInfo poi = cloudRoadData.getCoordinates().get( j );
|
||||
if ( poi == null ) {
|
||||
@@ -101,12 +115,14 @@ class SnapshotSetDataDrawer {
|
||||
}
|
||||
double lat = poi.getLat();
|
||||
double lng = poi.getLon();
|
||||
points.add( new MogoLatLng( lat, lng ) );
|
||||
points.add( endLatLon = new MogoLatLng( lat, lng ) );
|
||||
}
|
||||
|
||||
} else {
|
||||
points.add( marker.getPosition() );
|
||||
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
|
||||
points.add( endLatLon = new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
|
||||
}
|
||||
if ( endLatLon != null ) {
|
||||
marker.setPosition( endLatLon.lat, endLatLon.lon );
|
||||
}
|
||||
if ( points.size() >= 1 ) {
|
||||
marker.startSmooth( points, 1 );
|
||||
@@ -132,6 +148,9 @@ class SnapshotSetDataDrawer {
|
||||
continue;
|
||||
}
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( TextUtils.isEmpty( uniqueKey ) ) {
|
||||
continue;
|
||||
}
|
||||
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
existMarker.put( uniqueKey, mCloudSnapshotMarkersCaches.get( uniqueKey ) );
|
||||
}
|
||||
@@ -159,10 +178,19 @@ class SnapshotSetDataDrawer {
|
||||
if ( data.getType() == AdasRecognizedType.classIdBackground ) {
|
||||
|
||||
}
|
||||
Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
|
||||
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) )
|
||||
.icon( inflateView( data ) )
|
||||
.gps( true )
|
||||
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
|
||||
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
|
||||
}
|
||||
|
||||
private View inflateView( CloudRoadData data ) {
|
||||
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
|
||||
TextView tv = rootView.findViewById( R.id.tvSn );
|
||||
tv.setText( data.getUniqueKey() );
|
||||
return rootView;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.module.common.drawer.marker;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/29
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class MarkerResourceManager {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user