react-native - error navigate with react-native-open-maps
问题描述
i tried to navigate to my maps in my phone (googleMap or iphoneMaps) with react-native-open-maps but when it opens the map it doesnt show me the specific place and i cant navigate to this place. if anyone can help me how to navigate to a specific location i will be greatful
import createOpenLink from 'react-native-open-maps';
<MapView
style={{ flex: 0.8, width: Dimensions.get('window').width }}
region={{
latitude: currentElement.coordinates.latitude,
longitude: currentElement.coordinates.longitude,
latitudeDelta: 0.122,
longitudeDelta: 0.121,
}} >
<Marker
onPress={() => openYosemiteZoomedOut(currentElement.coordinates.latitude,currentElement.coordinates.longitude)}
coordinate={{
latitude: currentElement.coordinates.latitude,
longitude: currentElement.coordinates.longitude,
}}
/>
</MapView>
const openYosemiteZoomedOut =(lat,long)=>{ createOpenLink({latitude:lat,longitude:long,zoom:30 });}
解决方案
使用此代码而不是使用库
if (Platform.OS === 'android') {
Linking.openURL(`geo:0,0?q=${latitude},${longitude}(${info})`)
.catch(err => console.error('An error occurred', err));
} else {
Linking.openURL(`http://maps.apple.com/?ll=${latitude},${longitude}&q=${info}`)
.catch(err => console.error('An error occurred', err));
}
推荐阅读
- plot - 箱线图,八度图
- java - 如何将 JtextArea 焦点设置在正确的位置?
- spring-boot - 功能区 MaxAutoRetries 属性不起作用
- python - 使用 Keras 连接隐藏单元
- php - 根据用户 id 检索数据 (CodeIgniter)
- php - 将 ZOHO API 与 Laravel 5.7 集成
- scala - 将 Guava 期货转换为 Twitter 期货
- c# - 在导入数据库之前验证 Excel 文件数据
- java - 使用 maven-jaxb2-plugin 后在 Eclipse 中生成的包名错误
- c# - 在 C# winforms 中使用 SQLite