使用'react-native-maps'构建应用程序时出现问题
这是我的setting.gradle文件
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/android')
Run Code Online (Sandbox Code Playgroud)
android/app/build.gradle文件的依赖项
dependencies {
compile project(':react-native-maps')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.airbnb.android:react-native-maps:0.6.0'
}
Run Code Online (Sandbox Code Playgroud)
这是我使用MapsPackage()更新的MainActivity.java文件
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new MapsPackage()
);
}
Run Code Online (Sandbox Code Playgroud)
即将发生的错误:
JS服务器已经运行.在设备上构建和安装应用程序(cd android && gradlew.bat install Debug ...
FAILURE:构建因异常而失败.
出了什么问题:配置项目':app'时出现问题.
无法评估模块react-native-maps:找不到名称为"default"的配置.
尝试:使用--stacktrace选项运行以获取堆栈跟踪.使用--info或--debug选项运行以获取更多日志输出.
建筑失败
总时间:13.479秒无法在设备上安装应用程序,请阅读上述错误以获取详细信息.
我已经提到了给定链接中提到的所有程序https://github.com/lelandrichardson/react-native-maps/blob/master/docs/installation.md
我也看过https://github.com/lelandrichardson/react-native-maps/issues/288但无法解决错误
请帮忙提前谢谢
我已经在react-native中创建了地图,参考https://github.com/lelandrichardson/react-native-maps 地图已创建,但我想使用gps检测自动位置.以下是使用静态纬度和经度渲染地图的代码.这是我更新的代码.但它仍然没有呈现完美的位置
getInitialState() {
return {
initialPosition: 'unknown',
lastPosition: 'unknown',
};
},
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
var initialPosition = JSON.stringify(position);
this.setState({initialPosition});
},
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
this.watchID = navigator.geolocation.watchPosition((position) => {
var lastPosition = JSON.stringify(position);
this.setState({lastPosition});
});
},
componentWillUnmount() {
navigator.geolocation.clearWatch(this.watchID);
},
render() {
return (
<View style={styles.container}>
<MapView
ref="map"
mapType="terrain"
style={styles.map}
initialPosition={this.state.initialPosition}
lastPosition={this.state.lastPosition}
>
</MapView>
</View>
Run Code Online (Sandbox Code Playgroud)
你能纠正吗?
提前致谢
嘿家伙我是新来回应当地尝试建立汉堡包抽屉协助导航,但无法找到适当的文件.我发现了一个,但它是用redux,所以我放手了.任何人都可以指导我如何为react-native应用程序创建drawerlayout.提前致谢.
嘿,我正在尝试添加覆盖标记,即使我们滚动或缩放屏幕,它也会像这样保持在屏幕的中心
我尝试从其初始位置移动标记,但是当我们快速移动屏幕时它会落后。所以我想在屏幕中央设置标记图像
这是我为移动标记所做的代码:
componentDidMount: function() {
this.fetchData();
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
region: {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
});
},
);
this.watchID = navigator.geolocation.watchPosition((position) => {
const newRegion = {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
}
this.onRegionChange(newRegion);
});
},
componentWillUnmount: function() {
navigator.geolocation.clearWatch(this.watchID);
},
onRegionChange(region) {
this.setState({ region });
},
Run Code Online (Sandbox Code Playgroud)
那么如何覆盖标记图像?
嘿家伙我正在尝试将我的react-native apk上传到redmi note 3但是在将gradle从1.3.1降级到1.2.3之后遇到了无法上传一些apk的错误我能够找到它但仍然成功上传应用程序之后我只能看到空白的白色屏幕.我无法看到我关注的任何应用程序屏幕https://github.com/facebook/react-native/issues/2720但仍然没有找到任何成功.我曾经工作过两个版本的redmi手机,一个是带有5.0.2安卓版本的redmi note 3和带有4.4.4 android版本的Mi pad,并且在两个空白屏幕上都面临同样的问题.提前致谢.
嘿伙计们,我正在尝试使用es6在react-native中创建空数组.但在访问它时,我得到一个未定义的错误数据.
这是我用来初始化数组的代码片段.
constructor() {
super();
this.state = {
search: "",
data: []
}
}
Run Code Online (Sandbox Code Playgroud)
这是我试图填充数组并同时记录它的代码
.then((responseData) => {
this.setState({
data: responseData.hits.hits.map(function(search){
return{
name: search._source.service_name
}
})
})
console.log(data);
Run Code Online (Sandbox Code Playgroud)
我认为阵列的初始化存在问题,任何人都可以纠正它吗?提前致谢
react-native ×6
android ×4
javascript ×3
maps ×2
apk ×1
arrays ×1
css ×1
ecmascript-6 ×1
google-maps ×1
gps ×1
gradle ×1
marker ×1
menu ×1
reactjs ×1