Browse Source

fix: 修复关闭map view没有调用onDestroy问题

hwh97 5 years ago
parent
commit
38ed510f00
1 changed files with 5 additions and 5 deletions
  1. 5 5
      android/src/main/kotlin/com/i2edu/amap_location/AMapView.kt

+ 5 - 5
android/src/main/kotlin/com/i2edu/amap_location/AMapView.kt

@@ -84,16 +84,16 @@ class AMapView(private val context: Context, private val channel: MethodChannel)
             frameLayout?.removeView(mapView)
             frameLayout = null
         }
+        if (aMap != null) {
+            aMap?.setOnMyLocationChangeListener(null)
+            aMap = null
+        }
         if (mapView != null) {
+            mapView?.onDestroy()
             mapView?.removeAllViews()
             infoWindow = null
             mapView = null
         }
-        aMap?.setOnMyLocationChangeListener(null)
-        if (aMap != null) {
-            aMap = null
-        }
-        mapView?.onDestroy()
     }
 
     override fun onMyLocationChange(p0: Location) {