geometry - React Native 地图 - 渲染一个可拖动(可调整大小)的圆圈
问题描述
我想知道如何将圆渲染到可拖动的 MapView 上,因为您拖动圆的外周,并且半径根据拖动方向而变化。然后至关重要的是,能够以米为单位捕获这个半径。
我什至不知道如何开始,但我可以向您展示我是如何渲染我的圆形组件的。它呈现完美,并在我移动时随我移动。
<MapView.Circle
key = { (userPosition.longitude + userPosition.latitude).toString() }
center = { userPosition }
radius = { this.props.circleRadius }
strokeWidth = { 1 }
strokeColor = { '#1a66ff' }
fillColor = { 'rgba(230,238,255,0.5)' }
onRegionChangeComplete = { this.onRegionChangeComplete.bind(this) }
/>
是否存在我不知道的 MapView.Circle 属性?还是我必须为此构建自己的自定义组件?
这肯定是可能的吗?
解决方案
对于任何寻找自定义解决方案的人,您可以执行类似的操作:
<Marker
coordinate={coord}
fillColor={'rgba(101,75,169,0.5)'}
draggable
onDragEnd={(e) => {}}
onPress={(e) => {}}
>
<View
style={{
width: 20,
height: 20,
backgroundColor: 'rgba(101,75,169,0.75)',
borderRadius: 10,
borderColor: 'black',
borderWidth: 1
}}
/>
</Marker
推荐阅读
- python - 如何将列表中的字符串与列表理解结合起来?
- python - Kivy:按下按钮时更新TextInput
- react-native - Expo-React-native-map:从用户当前位置的 5 公里半径范围内查找最近的餐馆
- java - MySQL /Java 帮助 - 通过 eclipse 更新方法
- visual-studio-code - 如何在 VS TextMateRules 中使标记变为粗体+斜体
- c++ - 你如何在 macOS 上使用 Valgrind/Helgrind?
- android - Android 版本构建错误:“无法进一步更改此属性的值。”
- react-native - React Native 和嵌套导航,好方法?
- java - 我正在尝试在 aes 算法中打印密钥。但打印的密钥大小不是 128 位
- wordpress - 仅主页将子域重写为域失败