android - 无法在单个配置中同时重置俯仰、航向、边界、中心坐标
问题描述
当我尝试在单个配置中设置相机的俯仰、航向、边界和中心坐标时,我遇到了这个奇怪的问题。
最初,这是我拥有的相机的配置 -
间距:0
标题:0
bounds:一些坐标边界
中心坐标:空
这些值通过 props 传递给相机,如下所示 -
const {
followUserLocation,
heading,
pitch,
animationDuration,
zoomLevel,
centerCoordinate,
bounds
} = this.state;
<MapboxGL.Camera
ref={camera => (this._camera = camera)}
bounds={bounds}
centerCoordinate={centerCoordinate}
heading={heading}
pitch={pitch}
animationDuration={animationDuration}
zoomLevel={zoomLevel}
followUserLocation={locationPermissionGranted ?
followUserLocation : false}
followUserMode={'normal'}
/>
在某些外部事件上,我收到一组航点,我想更新俯仰和航向,并将相机聚焦在每个外部事件的每个航点上(例如单击下一个/上一个按钮)。所以我做以下 -
this.setState({
pitch: 60,
heading: someHeading,
animationDuration: 400,
bounds: undefined,
centerCoordinate: nextWaypoint,
zoomLevel
})
我的相机正确地更新了俯仰,航向,删除了默认边界并立即正确地聚焦到中心坐标。
当我尝试将相机“重置”到默认阶段时出现问题 - 重置俯仰、航向、清除 centerCoordinate 并使用 setState 设置一些边界 -
this.setState({
heading: 0, //reset
pitch: 0, //reset
animationDuration: 1000,
bounds : defaultBounds,
centerCoordinate: null, //reset
zoomLevel: undefined // reset
})
当我这样做时,相机没有正确重置到默认位置 - 俯仰和航向没有重置(采用旧的)并且边界也没有正确设置。
当我尝试先设置音高和航向时,添加一些超时然后设置界限,它可以工作,但不能单打。我做错了什么还是这是一个已知的错误?
当地图框完成加载时,即触发 onDidFinishLoadingMap 事件时,我正在执行所有这些操作。
我也尝试使用setCamera(cameraConfig)
函数而不是状态方法,但得到了相同的结果。
平台:安卓、IOS
版本:7.0.0-rc3
RN 版本 - 0.59.10
解决方案
推荐阅读
- javascript - ReactJS 多级下拉菜单
- typescript - 类型错误:uuid_1.v5 不是函数
- ansible - 仅打印失败的任务 - Ansible
- python - 操作错误:光标“_django_curs_
“ 不存在 - java - 如何在Java中检查对象结果大于0
- python - 芹菜(4.2):如何获取当前任务的任务ID
- scala - Intellij 没有从 .ivy2 缓存文件夹中选择依赖项
- tfs - VSTS 可以使用本地服务器吗?不是云
- kubernetes - kubernetes,入口端口重定向问题
- android - 如何在android中获取自我广告地址