Commit d2b294e0 authored by 邱亚涛's avatar 邱亚涛 Committed by Qiu Xiang
Browse files

高德地图RN版本的很多修复与功能开发

本版本更新列表:
1. 高德地图升级到5.2.1,优化Android工程引用高德地图lib的方式
2. 修复地图组件中Marker或者Overlay无法动态变更调整的问题
3. 修复Android中地图点击、长按、用户位置更新接口未携带定位信息问题
4. 修复Android中地图移除后用户定位未关闭问题
5. 优化地图组件iOS中拖拽返回时卡顿问题
6. 实现地图组件设置地图可展示区域
7. 实现iOS支持animateTo交互操作,实现iOS和Android对duration的支持
8. 实现iOS和Android地图交互大一统接口:animateToMapStatus支持设置多个地图相机参数

9. 修复Android中点击地图后选中的Marker无法自动取消选中问题
10. 修复Marker上zIndex不生效问题
11. 修复iOS中点击Marker后导致地图点击事件回调的问题
12. 修复iOS中自定义的Marker图标在初次渲染时无法展示以及展示位置调整的问题
13. 修复iOS中Marker拖拽后变为大头针问题
14. 修复iOS中Marker自定义InfoWindow位置展示不正确与不接收用户点击事件的问题
15. 修复iOS Marker初始化active参数不生效问题

16. 修复Android中线段opacity不生效问题,实现iOS对opacity的支持
17. 实现iOS支持多颜色线段渐变渲染功能

后续待开发列表:
1. 弄清室内地图不生效问题
2. 支持地图自定义样式设置
3. 更加丰富的地图事件
4. 实现iOS中Overlay支持zIndex设置,添加Overlay地图层次定义

# Conflicts:
#	android/src/main/java/cn/qiuxiang/react/amap3d/AMapView.kt
#	android/src/main/java/cn/qiuxiang/react/amap3d/AMapViewManager.kt
#	components/MapView.js

close #5
parent 41679a8b
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
package cn.qiuxiang.react.amap3d

import com.amap.api.maps.model.LatLng
import com.amap.api.maps.model.LatLngBounds
import com.facebook.react.bridge.ReadableMap
import android.graphics.Color

/**
 * Created by yuekong on 2017/7/4.
 */
class AMapConverter {
    companion object {
        fun LatLng(map: ReadableMap): LatLng {
            return LatLng(map.getDouble("latitude"), map.getDouble("longitude"))
        }

        fun LatLngDelta(map: ReadableMap): LatLng {
            return LatLng(map.getDouble("latitudeDelta"), map.getDouble("longitudeDelta"))
        }

        fun LatLngBounds(map: ReadableMap): LatLngBounds {
            val center = LatLng(map.getMap("center"))
            val span = LatLngDelta(map.getMap("span"))
            return LatLngBounds(
                    LatLng(center.latitude - span.latitude, center.longitude - span.longitude),
                    LatLng(center.latitude + span.latitude, center.longitude + span.longitude)
            )
        }

        fun color(color: Int, opacity: Float): Int {
            return Color.argb(((opacity * Color.alpha(color)).toInt()), Color.red(color), Color.green(color), Color.blue(color))
        }
    }
}
 No newline at end of file
+8 −1
Original line number Diff line number Diff line
@@ -35,6 +35,12 @@ class AMapMarker(context: ThemedReactContext) : ReactViewGroup(context) {
            marker?.position = value
        }

    var zIndex: Float = 0.0f
        set(value) {
            field = value
            marker?.zIndex = value
        }

    var title = ""
        set(value) {
            field = value
@@ -86,7 +92,8 @@ class AMapMarker(context: ThemedReactContext) : ReactViewGroup(context) {
                .position(position)
                .title(title)
                .infoWindowEnable(infoWindowEnabled)
                .snippet(snippet))
                .snippet(snippet)
                .zIndex(zIndex))

        if (active) {
            marker?.showInfoWindow()
+5 −0
Original line number Diff line number Diff line
@@ -81,4 +81,9 @@ internal class AMapMarkerManager : ViewGroupManager<AMapMarker>() {
    fun setEnabledInfoWindow(marker: AMapMarker, enabled: Boolean) {
        marker.infoWindowEnabled = enabled
    }

    @ReactProp(name = "zIndex")
    fun setZInex(marker: AMapMarker, zIndex: Float) {
        marker.zIndex = zIndex
    }
}
+13 −2
Original line number Diff line number Diff line
package cn.qiuxiang.react.amap3d

import android.annotation.SuppressLint
import android.view.View
import com.amap.api.maps.AMap
import com.amap.api.maps.CameraUpdateFactory
@@ -31,10 +32,14 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
        map.myLocationStyle = locationStyle

        map.setOnMapClickListener { latLng ->
            for (marker in markers.values) {
                marker.active = false
            }

            val event = Arguments.createMap()
            event.putDouble("latitude", latLng.latitude)
            event.putDouble("longitude", latLng.longitude)
            emit(id, "onMapClick")
            emit(id, "onMapClick", event)
        }

        map.setOnMapLongClickListener { latLng ->
@@ -49,7 +54,7 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
            event.putDouble("latitude", location.latitude)
            event.putDouble("longitude", location.longitude)
            event.putDouble("accuracy", location.accuracy.toDouble())
            emit(id, "onLocationChange")
            emit(id, "onLocationChange", event)
        }

        map.setOnMarkerClickListener { marker ->
@@ -86,6 +91,12 @@ class AMapView(context: ThemedReactContext) : MapView(context) {
        map.setInfoWindowAdapter(InfoWindowAdapter(context, markers))
    }

    @SuppressLint("MissingSuperCall")
    override fun onDetachedFromWindow() {
        super.onDetachedFromWindow()
        map.isMyLocationEnabled = false
    }

    fun addMarker(marker: AMapMarker) {
        marker.addToMap(map)
        markers.put(marker.marker?.id!!, marker)
+6 −3
Original line number Diff line number Diff line
@@ -13,9 +13,7 @@ import com.facebook.react.uimanager.annotations.ReactProp
@Suppress("unused")
internal class AMapViewManager : ViewGroupManager<AMapView>() {
    companion object {
        val ANIMATE_TO_COORDINATE = 1
        val ANIMATE_TO_ZOOM_LEVEL = 2
        val ANIMATE_TO = 3
        val ANIMATE_TO = 1
    }

    override fun getName(): String {
@@ -163,6 +161,11 @@ internal class AMapViewManager : ViewGroupManager<AMapView>() {
                coordinate.getDouble("longitude"))))
    }

    @ReactProp(name = "limitRegion")
    fun setLimitRegion(view: AMapView, limitRegion: ReadableMap) {
        view.map.setMapStatusLimits(AMapConverter.LatLngBounds(limitRegion))
    }

    @ReactProp(name = "tilt")
    fun changeTilt(view: AMapView, tilt: Float) {
        view.map.moveCamera(CameraUpdateFactory.changeTilt(tilt))
Loading