Unverified Commit ea90f1ef authored by 7c00's avatar 7c00 Committed by GitHub

Merge pull request #301 from Qiu800820/master

add locationType(only android)
parents 5e411d6a a4c4a917
......@@ -227,4 +227,9 @@ class AMapView(context: Context) : TextureMapView(context) {
locationStyle.myLocationIcon(BitmapDescriptorFactory.fromResource(drawable))
}
}
fun setLocationType(type: Int) {
locationStyle.myLocationType(type)
map.myLocationStyle = locationStyle
}
}
......@@ -4,6 +4,7 @@ import android.view.View
import com.amap.api.maps.AMap
import com.amap.api.maps.CameraUpdateFactory
import com.amap.api.maps.model.LatLng
import com.amap.api.maps.model.MyLocationStyle
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.common.MapBuilder
......@@ -194,4 +195,18 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
fun setLocationStyle(view: AMapView, style: ReadableMap) {
view.setLocationStyle(style)
}
@ReactProp(name = "locationType")
fun setLocationStyle(view: AMapView, type: String) {
when (type) {
"show" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_SHOW)
"locate" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_LOCATE)
"follow" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW)
"map_rotate" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE)
"location_rotate" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE)
"location_rotate_no_center" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER)
"follow_no_center" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_FOLLOW_NO_CENTER)
"map_rotate_no_center" -> view.setLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE_NO_CENTER)
}
}
}
......@@ -39,6 +39,14 @@ export default class MapView extends Component<any> {
*/
locationStyle: LocationStyle,
/**
* 设置定位模式 默认 LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER
*
* @platform android
*/
locationType: PropTypes.oneOf(['show', 'locate', 'follow', 'map_rotate', 'location_rotate',
'location_rotate_no_center', 'follow_no_center', 'map_rotate_no_center']),
/**
* 是否启用定位
*/
......
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