opt
This commit is contained in:
@@ -16,6 +16,7 @@ import android.view.animation.Interpolator;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.AMapUtils;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.LocationSource;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
@@ -78,6 +79,9 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
private EnumMapUI mCurrentUIMode;
|
||||
|
||||
// 自定义定位源的回调信息,前瞻线
|
||||
private LocationSource.OnLocationChangedListener mOnLocationChangedListener;
|
||||
|
||||
public AMapNaviViewWrapper( AMapNaviView mapView ) {
|
||||
this.mMapView = mapView;
|
||||
this.mIMap = new AMapWrapper( mMapView.getMap(), mMapView, this );
|
||||
@@ -197,6 +201,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
initMapView();
|
||||
initListeners();
|
||||
initMyLocation();
|
||||
initLocationSource();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,6 +523,22 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
}
|
||||
}
|
||||
|
||||
private void initLocationSource(){
|
||||
if ( checkAMapView() ) {
|
||||
mMapView.getMap().setLocationSource( new LocationSource() {
|
||||
@Override
|
||||
public void activate( OnLocationChangedListener onLocationChangedListener ) {
|
||||
AMapNaviViewWrapper.this.mOnLocationChangedListener = onLocationChangedListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoverLockMode() {
|
||||
if ( checkAMapView() ) {
|
||||
@@ -752,4 +773,11 @@ public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
public EnumMapUI getCurrentUiMode() {
|
||||
return mCurrentUIMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMyLocation( Location location ) {
|
||||
if ( mOnLocationChangedListener != null ) {
|
||||
mOnLocationChangedListener.onLocationChanged( location );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.LocationSource;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
|
||||
@@ -8,7 +8,12 @@ import android.text.TextUtils;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.MarkerOptionsCreator;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.navi.AMapNavi;
|
||||
import com.amap.api.navi.model.AMapNaviLocation;
|
||||
@@ -66,6 +71,11 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
private CalculatePathItem mSelectedCalculatePathItem;
|
||||
private OnCalculatePathItemClickInteraction mLineClickInteraction;
|
||||
|
||||
/**
|
||||
* 起点终点marker
|
||||
*/
|
||||
private List< Marker > mMarkers = new ArrayList<>();
|
||||
|
||||
public NaviOverlayHelper( AMapNavi mAMapNavi, AMap mAMap, Context mContext ) {
|
||||
this.mAMapNavi = mAMapNavi;
|
||||
this.mAMap = mAMap;
|
||||
@@ -182,9 +192,9 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.ic_endpoint );
|
||||
Bitmap startBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.ic_navi_start );
|
||||
Bitmap endBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.ic_navi_target );
|
||||
MogoMarkerOptions options = new MogoMarkerOptions().icon( bitmap ).zIndex( 0 ).anchor( 0.5f, 0.5f );
|
||||
MogoMarkerOptions startOptions = new MogoMarkerOptions().icon( startBitmap ).zIndex( 0 ).anchor( 0.5f, 1 );
|
||||
MogoMarkerOptions endOptions = new MogoMarkerOptions().icon( endBitmap ).zIndex( 0 ).anchor( 0.5f, 1 );
|
||||
MarkerOptions options = new MarkerOptions().icon( BitmapDescriptorFactory.fromBitmap( bitmap ) ).zIndex( 0 ).anchor( 0.5f, 0.5f );
|
||||
MarkerOptions startOptions = new MarkerOptions().icon( BitmapDescriptorFactory.fromBitmap( startBitmap ) ).zIndex( 0 ).anchor( 0.5f, 1 );
|
||||
MarkerOptions endOptions = new MarkerOptions().icon( BitmapDescriptorFactory.fromBitmap( endBitmap ) ).zIndex( 0 ).anchor( 0.5f, 1 );
|
||||
for ( CalculatePathItem path : mCalculatePathItems ) {
|
||||
List< MogoLatLng > points = path.getCoordList();
|
||||
if ( points == null || points.isEmpty() ) {
|
||||
@@ -195,10 +205,10 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
if ( startPoint == null || endPoint == null ) {
|
||||
continue;
|
||||
}
|
||||
MogoMap.getInstance().getMogoMap().addMarker( TAG, options.latitude( startPoint.lat ).longitude( startPoint.lng ) );
|
||||
MogoMap.getInstance().getMogoMap().addMarker( TAG, options.latitude( endPoint.lat ).longitude( endPoint.lng ) );
|
||||
MogoMap.getInstance().getMogoMap().addMarker( TAG, startOptions.latitude( startPoint.lat ).longitude( startPoint.lng ) );
|
||||
MogoMap.getInstance().getMogoMap().addMarker( TAG, endOptions.latitude( endPoint.lat ).longitude( endPoint.lng ) );
|
||||
mMarkers.add( mAMap.addMarker( options.position( new LatLng( startPoint.lat, startPoint.lng ) ) ) );
|
||||
mMarkers.add( mAMap.addMarker( options.position( new LatLng( endPoint.lat, endPoint.lng ) ) ) );
|
||||
mMarkers.add( mAMap.addMarker( startOptions.position( new LatLng( startPoint.lat, startPoint.lng ) ) ) );
|
||||
mMarkers.add( mAMap.addMarker( endOptions.position( new LatLng( endPoint.lat, endPoint.lng ) ) ) );
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -221,6 +231,19 @@ public class NaviOverlayHelper implements OnCalculatePathItemClickInteraction {
|
||||
if ( mPaths != null ) {
|
||||
mPaths.clear();
|
||||
}
|
||||
if ( !mMarkers.isEmpty() ) {
|
||||
for ( Marker mMarker : mMarkers ) {
|
||||
if ( mMarker == null ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
mMarker.remove();
|
||||
mMarker.destroy();
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
MogoMarkersHandler.getInstance().remove( TAG );
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map.impl.amap.uicontroller;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.location.Location;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
@@ -233,4 +234,11 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMyLocation( Location location ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.changeMyLocation( location );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user