From d7ee06d806afc466281e638c03a003033ddcdbe1 Mon Sep 17 00:00:00 2001 From: wangcongtao Date: Fri, 11 Sep 2020 15:37:32 +0800 Subject: [PATCH] fix: bugly#11002 --- .../mogo/map/impl/amap/AMapNaviViewWrapper.java | 16 ++++++++++++---- .../com/mogo/map/impl/amap/AMapViewWrapper.java | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index 24f557de14..d2e2aaf6e6 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -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() ) { diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java index 7b6e72ea7a..f189b0646e 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java @@ -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 {