qiuxiang / react-native-amap3d

react-native 高德地图组件,使用最新 3D SDK,支持 Android + iOS
https://qiuxiang.github.io/react-native-amap3d/api/
MIT License
1.27k stars 327 forks source link

ios 设备上onCameraIdle一直在调用,android设备上this.mapView?.moveCamera({target: location, zoom: 16});调用没反应 #802

Closed inkcrazy666 closed 10 months ago

inkcrazy666 commented 12 months ago
 "react": "16.11.0",
    "react-native": "0.63.5",
    "react-native-amap-geolocation": "^1.2.3",
    "react-native-amap3d": "^3.2.4",

场景:我们是用于考勤打卡的,有个服务器获取的公司定位companyLocation和当前定位location,如果等数据一起到位的话,再去加载地图感觉有点慢。所以我就用了默认北京的定位,先把地图显示出来,然后再去刷新居中的定位CameraPosition,发现如题问题

      <View style={styles.mapView}>
        <MapView
          ref={(ref) => (this.mapView = ref)}
          style={styles.mapView}
          onCameraIdle={() => {
            console.log('onCameraIdle');
            this.mapView?.moveCamera({target: location, zoom: 16});
          }}
          // onLoad={() => {
          //   console.log('onLoad');
          //   this.mapView?.moveCamera({target: location, zoom: 16});
          // }}
          mapType={MapType.Standard}
          // scrollGesturesEnabled={false} //是否启用滑动手势,用于平移
          tiltGesturesEnabled={false} //是否启用倾斜手势,用于改变视角
          // zoomGesturesEnabled={false} //是否启用缩放手势,用于放大缩小
          // myLocationEnabled={true}
          initialCameraPosition={{
            target: location,
            zoom: 16,
          }}>
          <Circle
            strokeWidth={1}
            strokeColor="rgba(54, 207, 201, 0.80)"
            fillColor="rgba(54, 207, 201, 0.20)"
            radius={range}
            center={companyLocation}
          />
          <Marker
            position={companyLocation}
            icon={require('../res/img/ic_enterprise_location.png')}
          />
          <Marker
            position={location}
            icon={require('../res/img/ic_current_location_marker.png')}
          />
        </MapView>
      </View>
inkcrazy666 commented 12 months ago

在iOS上,跟onCameraIdle方法里面调this.mapView?.moveCamera({target: location, zoom: 16});也有关系,moveCamera方法不调用的话,onCameraIdle不会一直调用

ghost commented 11 months ago

解决了吗

xiaomingge1 commented 10 months ago

解决了吗

durationMs must be positive 老哥我知道了,报错信息我没看到,参数duration不能缺省