瀏覽代碼

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

hwh97 5 年之前
父節點
當前提交
38ed510f00
共有 1 個文件被更改,包括 5 次插入5 次删除
  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) {