Skip to content

Commit

Permalink
修正 android marker 图标可能不更新的 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuxiang committed Dec 14, 2021
1 parent 7520135 commit c0f7c1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions example/screens/marker-dynamic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default () => {
return (
<MapView
onPress={({ nativeEvent }) => {
console.log(nativeEvent);
setMarkers([...markers, nativeEvent]);
}}
>
Expand All @@ -19,7 +18,6 @@ export default () => {
position={position}
onPress={() => {
markers.splice(markers.indexOf(position), 1);
console.log(markers);
setMarkers([...markers]);
}}
/>
Expand Down
6 changes: 5 additions & 1 deletion lib/android/src/main/java/qiuxiang/amap3d/map_view/Marker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package qiuxiang.amap3d.map_view
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Handler
import android.os.Looper
import android.view.View
import com.amap.api.maps.AMap
import com.amap.api.maps.model.*
Expand Down Expand Up @@ -74,7 +76,9 @@ class Marker(context: Context) : ReactViewGroup(context), Overlay {
fun setIcon(source: ReadableMap) {
fetchImage(source) {
icon = it
marker?.setIcon(it)
Handler(Looper.getMainLooper()).post {
marker?.setIcon(it)
}
}
}

Expand Down

0 comments on commit c0f7c1f

Please sign in to comment.