expo-gaode-map 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,8 +15,6 @@ class ExpoGaodeMapViewModule : Module() {
15
15
 
16
16
  // ✅ 关键修复:拦截 React Native 的视图操作异常
17
17
  OnViewDestroys { view: ExpoGaodeMapView ->
18
- // 在视图销毁时不做任何抛出异常的操作
19
- android.util.Log.d("ExpoGaodeMapViewModule", "视图正在销毁,清理资源")
20
18
  }
21
19
 
22
20
  Prop<Int>("mapType") { view, type ->
@@ -117,9 +117,6 @@ class OverlayManager(private val aMap: AMap, private val context: Context) {
117
117
  // ==================== 标记点 ====================
118
118
 
119
119
  fun addMarker(id: String, props: Map<String, Any>) {
120
- Log.d(TAG, "addMarker 调用 - ID: $id")
121
- Log.d(TAG, "addMarker props: $props")
122
-
123
120
  @Suppress("UNCHECKED_CAST")
124
121
  val position = props["position"] as? Map<String, Double>
125
122
  val title = props["title"] as? String
@@ -219,31 +216,24 @@ class OverlayManager(private val aMap: AMap, private val context: Context) {
219
216
  private fun loadMarkerIcon(uri: String, width: Int, height: Int, callback: (Bitmap) -> Unit) {
220
217
  Thread {
221
218
  try {
222
- Log.d(TAG, "开始加载图标: $uri")
223
219
  val bitmap = when {
224
220
  uri.startsWith("http://") || uri.startsWith("https://") -> {
225
- Log.d(TAG, "加载网络图片")
226
221
  BitmapFactory.decodeStream(URL(uri).openStream())
227
222
  }
228
223
  uri.startsWith("file://") -> {
229
- Log.d(TAG, "加载本地文件")
230
224
  BitmapFactory.decodeFile(uri.substring(7))
231
225
  }
232
226
  else -> {
233
- Log.d(TAG, "未知 URI 格式")
234
227
  null
235
228
  }
236
229
  }
237
230
 
238
- if (bitmap == null) {
239
- Log.e(TAG, "图标加载失败: bitmap 为 null")
240
- } else {
241
- Log.d(TAG, "图标加载成功: ${bitmap.width}x${bitmap.height}")
231
+ if (bitmap != null) {
242
232
  val resized = Bitmap.createScaledBitmap(bitmap, width, height, true)
243
233
  callback(resized)
244
234
  }
245
235
  } catch (e: Exception) {
246
- Log.e(TAG, "图标加载异常: ${e.message}", e)
236
+ // 忽略异常
247
237
  }
248
238
  }.start()
249
239
  }
@@ -353,10 +343,9 @@ class OverlayManager(private val aMap: AMap, private val context: Context) {
353
343
  bitmap?.let {
354
344
  val descriptor = BitmapDescriptorFactory.fromBitmap(it)
355
345
  polyline.setCustomTexture(descriptor)
356
- Log.d(TAG, "✅ 纹理设置成功")
357
346
  }
358
347
  } catch (e: Exception) {
359
- Log.e(TAG, "纹理加载失败: ${e.message}")
348
+ // 忽略异常
360
349
  }
361
350
  }.start()
362
351
  }
@@ -430,7 +419,6 @@ class OverlayManager(private val aMap: AMap, private val context: Context) {
430
419
  val polygon = aMap.addPolygon(options)
431
420
  polygons[id] = polygon
432
421
  polygonIdMap[polygon] = id
433
- Log.d(TAG, "✅ 多边形创建成功")
434
422
  }
435
423
  }
436
424
 
@@ -86,8 +86,6 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
86
86
  * 设置是否显示用户位置
87
87
  */
88
88
  fun setShowsUserLocation(show: Boolean, followUserLocation: Boolean = false) {
89
- android.util.Log.d("UIManager", "🔵 setShowsUserLocation: show=$show, follow=$followUserLocation")
90
-
91
89
  if (show) {
92
90
  // 创建默认的定位样式
93
91
  if (currentLocationStyle == null) {
@@ -102,7 +100,6 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
102
100
  interval(2000) // 2秒定位一次
103
101
  showMyLocation(true)
104
102
  }
105
- android.util.Log.d("UIManager", "✨ 创建默认 MyLocationStyle,类型: ${if (followUserLocation) "FOLLOW" else "SHOW"}")
106
103
  } else {
107
104
  // 更新定位类型
108
105
  val locationType = if (followUserLocation) {
@@ -114,7 +111,6 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
114
111
  myLocationType(locationType)
115
112
  interval(2000)
116
113
  }
117
- android.util.Log.d("UIManager", "🔄 更新定位类型: ${if (followUserLocation) "FOLLOW" else "SHOW"}")
118
114
  }
119
115
 
120
116
  // 监听定位变化(用于通知 React Native)
@@ -131,12 +127,10 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
131
127
 
132
128
  // 启用定位(使用高德地图自己的定位)
133
129
  aMap.isMyLocationEnabled = true
134
- android.util.Log.d("UIManager", "✅ 定位已启用")
135
130
 
136
131
  } else {
137
132
  aMap.setOnMyLocationChangeListener(null)
138
133
  aMap.isMyLocationEnabled = false
139
- android.util.Log.d("UIManager", "❌ 定位已禁用")
140
134
  }
141
135
  }
142
136
 
@@ -150,20 +144,15 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
150
144
  }
151
145
 
152
146
  val providers = locationManager?.getProviders(true) ?: emptyList()
153
- android.util.Log.d("UIManager", "📡 可用的定位提供者: $providers")
154
147
 
155
- // 优先使用 GPS,其次是网络定位
156
148
  val provider = when {
157
149
  providers.contains(AndroidLocationManager.GPS_PROVIDER) -> {
158
- android.util.Log.d("UIManager", "✅ 使用 GPS 定位")
159
150
  AndroidLocationManager.GPS_PROVIDER
160
151
  }
161
152
  providers.contains(AndroidLocationManager.NETWORK_PROVIDER) -> {
162
- android.util.Log.d("UIManager", "✅ 使用网络定位")
163
153
  AndroidLocationManager.NETWORK_PROVIDER
164
154
  }
165
155
  else -> {
166
- android.util.Log.e("UIManager", "❌ 没有可用的定位提供者")
167
156
  return
168
157
  }
169
158
  }
@@ -179,16 +168,13 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
179
168
  // 立即获取最后已知位置
180
169
  val lastLocation = locationManager?.getLastKnownLocation(provider)
181
170
  if (lastLocation != null) {
182
- android.util.Log.d("UIManager", "📍 获取到最后已知位置: ${lastLocation.latitude}, ${lastLocation.longitude}")
183
171
  onLocationChanged(lastLocation)
184
- } else {
185
- android.util.Log.d("UIManager", "⏳ 等待首次定位...")
186
172
  }
187
173
 
188
174
  } catch (e: SecurityException) {
189
- android.util.Log.e("UIManager", "❌ 定位权限未授予: ${e.message}")
175
+ // 忽略异常
190
176
  } catch (e: Exception) {
191
- android.util.Log.e("UIManager", "❌ 启动定位失败: ${e.message}", e)
177
+ // 忽略异常
192
178
  }
193
179
  }
194
180
 
@@ -198,9 +184,8 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
198
184
  private fun stopRealLocation() {
199
185
  try {
200
186
  locationManager?.removeUpdates(this)
201
- android.util.Log.d("UIManager", "🛑 已停止系统定位")
202
187
  } catch (e: Exception) {
203
- android.util.Log.e("UIManager", "停止定位失败: ${e.message}")
188
+ // 忽略异常
204
189
  }
205
190
  }
206
191
 
@@ -208,9 +193,6 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
208
193
  * 位置变化回调
209
194
  */
210
195
  override fun onLocationChanged(location: Location) {
211
- android.util.Log.d("UIManager", "📍📍📍 系统定位回调: lat=${location.latitude}, lng=${location.longitude}, accuracy=${location.accuracy}m")
212
-
213
- // 通知高德地图
214
196
  locationChangedListener?.onLocationChanged(location)
215
197
 
216
198
  // 通知 React Native
@@ -222,15 +204,12 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
222
204
  }
223
205
 
224
206
  override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {
225
- android.util.Log.d("UIManager", "定位状态变化: provider=$provider, status=$status")
226
207
  }
227
208
 
228
209
  override fun onProviderEnabled(provider: String) {
229
- android.util.Log.d("UIManager", "✅ 定位提供者已启用: $provider")
230
210
  }
231
211
 
232
212
  override fun onProviderDisabled(provider: String) {
233
- android.util.Log.d("UIManager", "❌ 定位提供者已禁用: $provider")
234
213
  }
235
214
 
236
215
  /**
@@ -238,15 +217,12 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
238
217
  * 统一 iOS 和 Android 的 API
239
218
  */
240
219
  fun setUserLocationRepresentation(config: Map<String, Any>) {
241
- android.util.Log.d("UIManager", "🎨 setUserLocationRepresentation 被调用,配置: $config")
242
-
243
220
  if (currentLocationStyle == null) {
244
221
  currentLocationStyle = MyLocationStyle().apply {
245
222
  myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE)
246
223
  interval(2000)
247
224
  showMyLocation(true)
248
225
  }
249
- android.util.Log.d("UIManager", "创建新的 MyLocationStyle")
250
226
  }
251
227
 
252
228
  val style = currentLocationStyle!!
@@ -280,16 +256,10 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
280
256
  // 自定义图标 (image)
281
257
  val imagePath = config["image"] as? String
282
258
  if (imagePath != null && imagePath.isNotEmpty()) {
283
- android.util.Log.d("UIManager", "开始加载自定义定位图标: $imagePath")
284
-
285
- // 将 dp 转换为 px (与 iOS points 对应)
286
259
  val density = context.resources.displayMetrics.density
287
260
  val imageWidth = (config["imageWidth"] as? Number)?.let { (it.toFloat() * density).toInt() }
288
261
  val imageHeight = (config["imageHeight"] as? Number)?.let { (it.toFloat() * density).toInt() }
289
262
 
290
- android.util.Log.d("UIManager", "图标尺寸: width=$imageWidth, height=$imageHeight, density=$density")
291
-
292
- // 网络图片需要在后台线程加载
293
263
  if (imagePath.startsWith("http://") || imagePath.startsWith("https://")) {
294
264
  Thread {
295
265
  try {
@@ -300,7 +270,6 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
300
270
  android.graphics.Bitmap.createScaledBitmap(originalBitmap, imageWidth, imageHeight, true)
301
271
  } else originalBitmap
302
272
 
303
- android.util.Log.d("UIManager", "✅ 网络图片加载成功 (${scaledBitmap.width}x${scaledBitmap.height}),应用到定位样式")
304
273
  style.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap))
305
274
 
306
275
  // 重新应用样式并确保定位开启
@@ -308,17 +277,12 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
308
277
 
309
278
  // 如果定位没开,重新开启
310
279
  if (!aMap.isMyLocationEnabled) {
311
- android.util.Log.d("UIManager", "⚠️ 定位未启用,重新启用")
312
280
  aMap.isMyLocationEnabled = true
313
281
  }
314
-
315
- android.util.Log.d("UIManager", "✅ 定位样式重新应用完成,定位状态: ${aMap.isMyLocationEnabled}")
316
- } else {
317
- android.util.Log.e("UIManager", "❌ 网络图片加载失败: bitmap is null")
318
282
  }
319
283
  }
320
284
  } catch (e: Exception) {
321
- android.util.Log.e("UIManager", "❌ 加载网络图片异常: ${e.message}", e)
285
+ // 忽略异常
322
286
  }
323
287
  }.start()
324
288
  return // 异步加载,提前返回
@@ -328,24 +292,18 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
328
292
  try {
329
293
  val originalBitmap = when {
330
294
  imagePath.startsWith("file://") -> {
331
- android.util.Log.d("UIManager", "加载文件路径图片: ${imagePath.substring(7)}")
332
295
  BitmapFactory.decodeFile(imagePath.substring(7))
333
296
  }
334
297
  else -> {
335
- // 尝试从资源加载
336
298
  val fileName = imagePath.substringBeforeLast('.')
337
- android.util.Log.d("UIManager", "尝试从资源加载: $fileName")
338
299
  val resId = context.resources.getIdentifier(
339
300
  fileName,
340
301
  "drawable",
341
302
  context.packageName
342
303
  )
343
- android.util.Log.d("UIManager", "资源 ID: $resId")
344
304
  if (resId != 0) {
345
305
  BitmapFactory.decodeResource(context.resources, resId)
346
306
  } else {
347
- // 尝试直接作为文件路径
348
- android.util.Log.d("UIManager", "尝试作为文件路径加载: $imagePath")
349
307
  BitmapFactory.decodeFile(imagePath)
350
308
  }
351
309
  }
@@ -357,7 +315,6 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
357
315
  android.graphics.Bitmap.createScaledBitmap(originalBitmap, imageWidth, imageHeight, true)
358
316
  } else originalBitmap
359
317
 
360
- android.util.Log.d("UIManager", "✅ 本地图片加载成功 (${scaledBitmap.width}x${scaledBitmap.height}),应用到定位样式")
361
318
  style.myLocationIcon(BitmapDescriptorFactory.fromBitmap(scaledBitmap))
362
319
 
363
320
  // 重新应用样式并确保定位开启
@@ -365,24 +322,16 @@ class UIManager(private val aMap: AMap, private val context: Context) : Location
365
322
 
366
323
  // 如果定位没开,重新开启
367
324
  if (!aMap.isMyLocationEnabled) {
368
- android.util.Log.d("UIManager", "⚠️ 定位未启用,重新启用")
369
325
  aMap.isMyLocationEnabled = true
370
326
  }
371
-
372
- android.util.Log.d("UIManager", "✅ 定位样式重新应用完成,定位状态: ${aMap.isMyLocationEnabled}")
373
- } else {
374
- android.util.Log.e("UIManager", "❌ 本地图片加载失败: bitmap is null, path=$imagePath")
375
327
  }
376
328
  }
377
329
  } catch (e: Exception) {
378
- android.util.Log.e("UIManager", "❌ 加载本地图片异常: ${e.message}", e)
330
+ // 忽略异常
379
331
  }
380
332
  }.start()
381
333
  return // 异步加载,提前返回
382
334
  }
383
- } else {
384
- // 没有自定义图标,使用默认蓝点
385
- android.util.Log.d("UIManager", "使用默认定位图标(蓝点)")
386
335
  }
387
336
 
388
337
  // 立即应用样式(针对没有自定义图标的情况)
@@ -37,7 +37,6 @@ object SDKInitializer {
37
37
  AMapLocationClient.setApiKey(androidKey)
38
38
 
39
39
  } catch (e: Exception) {
40
- Log.e(TAG, "SDK 初始化失败", e)
41
40
  throw Exception("SDK 初始化失败: ${e.message}")
42
41
  }
43
42
  }