Commit 974bcf93 authored by 李元辉's avatar 李元辉

动态刷新图片功能

parent a96def48
...@@ -19,6 +19,7 @@ import com.facebook.react.views.view.ReactViewGroup ...@@ -19,6 +19,7 @@ import com.facebook.react.views.view.ReactViewGroup
class AMapSmoothMoveMarker(context: Context) : ReactViewGroup(context), AMapOverlay { class AMapSmoothMoveMarker(context: Context) : ReactViewGroup(context), AMapOverlay {
private var bitmapDescriptor: BitmapDescriptor? = null private var bitmapDescriptor: BitmapDescriptor? = null
private var coordinates: ArrayList<LatLng> = ArrayList() private var coordinates: ArrayList<LatLng> = ArrayList()
private var lastImage: String? = null
var marker: SmoothMoveMarker? = null var marker: SmoothMoveMarker? = null
private set private set
...@@ -29,8 +30,13 @@ class AMapSmoothMoveMarker(context: Context) : ReactViewGroup(context), AMapOver ...@@ -29,8 +30,13 @@ class AMapSmoothMoveMarker(context: Context) : ReactViewGroup(context), AMapOver
} }
fun setImage(name: String) { fun setImage(name: String) {
val drawable = context.resources.getIdentifier(name, "drawable", context.packageName) //重置图片
bitmapDescriptor = BitmapDescriptorFactory.fromResource(drawable) if(lastImage != name) {
val drawable = context.resources.getIdentifier(name, "drawable", context.packageName)
bitmapDescriptor = BitmapDescriptorFactory.fromResource(drawable)
lastImage = name
marker?.setDescriptor(bitmapDescriptor)
}
} }
fun setCoordinates(coordinates: ReadableArray) { fun setCoordinates(coordinates: ReadableArray) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment