console.error:“ react-native-maps” AirGoogleMaps目录必须添加到您的xCode项目中
尝试在react-native-maps模块中测试示例时出现此错误。
GitHub:https : //github.com/airbnb/react-native-maps/tree/master/example
显然,我应该将dir添加到我的Xcode项目中,但是我不知道如何添加它们。
我可以举一个将目录添加到Xcode项目的示例吗?
当用户按下标记时,我调用animateToCoordinate将标记置于屏幕中间.问题是,在animateToCoordinate完成动画之前,标注会被渲染到区域的位置,因此标注会在屏幕外显示.无论如何都要延迟标注显示,直到animateToRegion完成?还是有另一种方式可以完全解决这个问题,我没有看到?
<MapView
ref = {(mapView) => { _mapView = mapView; }}
style={styles.map}
region={this.state.mapRegion}
showsUserLocation = {true}
showsMyLocationButton = {true}
followUserLocation={true}
onRegionChange={this.onRegionChange.bind(this)}>
{data.near.map(marker =>
{if(marker.posts.length != 0){
return (
<MapView.Marker
coordinate={{latitude: marker.location.latitude,
longitude: marker.location.longitude}}
title={marker.name}
description={marker.description}
onPress={ e => _mapView.animateToCoordinate({
latitude: e.nativeEvent.coordinate.latitude,
longitude: e.nativeEvent.coordinate.longitude
}, 500)}
onCalloutPress={ e => this._onPressItem(marker.id)}
>
<Icon name="ios-pin" style={{ fontSize: 45, color: '#f04c34'}} />
<MapView.Callout
style={{ flex: -1, position: 'absolute', width: width}}>
<ListItem >
<Body >
<View style={{flex: 1,
flexDirection: 'row',
justifyContent: 'space-between',}}>
<Text style={{fontSize: 18, …Run Code Online (Sandbox Code Playgroud) 我正在使用airbnb的react-native-maps库来开发我的用于android的本机应用程序.此应用程序在主页上显示地图和汽车图标.
它工作正常但是当汽车在行驶并且汽车坐标连续变化时,地图不能平滑地渲染.带有汽车图标的MapView标记沿着路径从一个点跳到另一个点.我的期望是在地图上显示连续移动的物体,就像它在谷歌地图上显示的那样.
这是我的代码:
this.state = {
latitude: 22.55231,
longitude: 88.56772,
angle: 0
}
componentDidMount(){
navigator.geolocation.getCurrentPosition(
position => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
let angle = position.coords.heading;
this.setState({latitude, longitude, angle});
},
error => console.log(error),
{
// enableHighAccuracy: true
}
);
navigator.geolocation.watchPosition(
position => {
let latitude = position.coords.latitude;
let longitude = position.coords.longitude;
let angle = position.coords.heading;
this.setState({latitude, longitude, angle});
},
error => console.log(error),
{
// enableHighAccuracy: true
}
);
}
getMapRegion(){
return {
latitude: this.state.latitude,
longitude: this.state.longitude, …Run Code Online (Sandbox Code Playgroud) javascript react-native react-native-android react-native-maps
似乎edgePadding在fitToCoordinates函数中没有做任何事情.无论我设置哪个值,结果总是相同的.我尝试将顶部,右侧,左下角设置为0,300,将它们彼此更改...... mapview始终相同.
<MapView
ref={(ref) => { this.mapRef = ref }}
onLayout = { () => this.mapRef.fitToCoordinates([{longitude: x, latitude: y}], { edgePadding: { top: 0, right: 0, bottom: 120, left: 0 }, animated: false })}
/>
Run Code Online (Sandbox Code Playgroud)
我希望能够从给定的坐标缩小一点.在给定区域中没有LongitudeDelta或LatitudeDelta,因此我假设必须使用edgePadding参数进行缩小.
你以前遇到过这个问题吗?
react-native react-native-android react-native-ios react-native-maps
有没有办法将地图限制在特定区域,以便平移和缩放包含在该区域内,而外部的所有内容都被锁定?我想限制用户可以在地图上看到的区域。我通过react-native-maps使用谷歌地图https://github.com/react-community/react-native-maps
这是我的代码,目前您可以缩放多远或可以向两侧平移多少没有限制
<View style={styles.container}>
<MapView style={styles.map}
provider= { PROVIDER_GOOGLE }
customMapStyle={mapStyle}
initialRegion={{
latitude: 59.2937025,
longitude: 18.0813377,
latitudeDelta: 0.012,
longitudeDelta: 0.012,
}}
/>
</View>
Run Code Online (Sandbox Code Playgroud) 未处理的JS异常:不变违例:requireNativeComponent:在UIManager中找不到"AIRMap".
此错误位于:AIRMap中(在MapView.js:760处)在MapView中(在App.js:25处)在RCTView(在View.js:43)中的应用程序(在renderApplication.js:32中)在RCTView中(在View.js:43)在AppContainer的RCTView(在View.js:43中)(在renderApplication.js:31)
如何在本机ios中修复此错误?
我收到以下警告:“不再支持通过UIManager ['AIRMap']直接从UIManager访问视图管理器配置。改为使用UIManager.getViewManagerConfig('AIRMap')。” 自从我安装了react-native-maps软件包以来,它就一直在显示。我应该忽略它还是它的解决方案?
提前致谢
建立react-native-maps并尝试确定使用animateToRegion与animateCamera的优缺点。过去,我们按地区来处理所有事务。
似乎区域是一个更好的选择,因为您不必担心高程和缩放之间的差异,并且在需要时还可以更精确地控制要显示的确切区域。
任何人都有任何想法或经历使他们走向另一个?
我刚刚将我的应用程序从 Expo SDK 37.0.0 升级到 38.0.0。该应用程序在 iOS 上运行良好,但在 Android 上我收到以下警告,并且该应用程序无法在地图上对我进行地理定位。
开发环境:
预期结果:应用程序应根据我的位置对我(用户)进行地理定位。实际结果:应用程序不会根据我的位置对我(用户)进行地理定位。警告 :
[未处理的承诺拒绝:错误:位置提供商不可用。确保定位服务已启用。]
到目前为止我尝试过什么?
再次运行 expo 升级以确保所有软件包都设置为正确的版本。
删除 package-lock.json 和 node_modules 并运行 npm install。
设置 Location.getCurrentPositionAsync({accuracy:Location.Accuracy.High})
设置 Location.getCurrentPositionAsync({ enableHighAccuracy: true })
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
async _getLocationAsync() {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
/* If user hasn't granted permission to geolocate …Run Code Online (Sandbox Code Playgroud)反应本机:https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz 反应:16.13.1 反应本机地图:0.28.0
我想将标记作为快照的一部分。当我们使用takeSnapshot方法时,所有标记都将被忽略。
const snapshot = this.viewRefTest.takeSnapshot({
format: 'png', // image formats: 'png', 'jpg' (default: 'png')
quality: 0.5, // image quality: 0..1 (only relevant for jpg, default: 1)
result: 'file', // result types: 'file', 'base64' (default: 'file')
});
<MapView
ref={(viewRefTest) => {
this.viewRefTest = viewRefTest;
}}
showsUserLocation={true}
followUserLocation={true}>
<MapView.Marker coordinate={item.location}>
<Image
style={{ width: 30, height: 30 }}
source={require('../../assets/images/trophy.png')}
/>
<Callout style={{ width: 250, flexDirection: 'row', alignItems: 'center' }}>
<Text>$23</Text>
<View>
<Text style={{ fontSize: 12 }}>Custom Text!</Text> …Run Code Online (Sandbox Code Playgroud) react-native ×10
ios ×3
android ×2
javascript ×2
expo ×1
google-maps ×1
maps ×1
reactjs ×1
xcode ×1