fix: bugly#11002

This commit is contained in:
wangcongtao
2020-09-11 15:37:32 +08:00
parent b257744d84
commit d7ee06d806
2 changed files with 13 additions and 5 deletions

View File

@@ -522,7 +522,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
}
if ( checkAMapView() ) {
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
MyLocationStyle style = getMyLocationStyle();
if ( style == null ) {
style = new MyLocationStyle();
}
@@ -544,7 +544,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
}
if ( checkAMapView() ) {
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
MyLocationStyle style = getMyLocationStyle();
if ( style == null ) {
style = new MyLocationStyle();
}
@@ -557,7 +557,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
public void initMyLocation() {
if ( checkAMapView() ) {
mMapView.getMap().setMyLocationEnabled( true );
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
MyLocationStyle style = getMyLocationStyle();
style.myLocationType( MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER );
style.interval( 1000 );
style.anchor( 0.5F, 0.5F );
@@ -864,7 +864,7 @@ public class AMapNaviViewWrapper implements IMogoMapView,
if ( mMapView.getMap() == null ) {
return;
}
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
MyLocationStyle style = getMyLocationStyle();
if ( mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled() ) {
style.myLocationIcon( BitmapDescriptorFactory.fromBitmap( mCarCursorOption.getCarCursorBmp() ) );
} else {
@@ -877,6 +877,14 @@ public class AMapNaviViewWrapper implements IMogoMapView,
mMapView.getMap().setMyLocationStyle( style );
}
private MyLocationStyle getMyLocationStyle() {
try {
return mMapView.getMap().getMyLocationStyle();
} catch ( Exception e ) {
return new MyLocationStyle();
}
}
@Override
public MapCameraPosition getMapCameraPosition() {
if ( checkAMapView() ) {

View File

@@ -790,7 +790,7 @@ public class AMapViewWrapper implements IMogoMapView,
if ( mMapView.getMap() == null ) {
return;
}
MyLocationStyle style = mMapView.getMap().getMyLocationStyle();
MyLocationStyle style = getMyLocationStyle();
if ( mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled() ) {
style.myLocationIcon( BitmapDescriptorFactory.fromBitmap( mCarCursorOption.getCarCursorBmp() ) );
} else {