Google maps 如何在IOS和Android上定制/设置Expo中的MapView?
我已经在上生成了一个样式,它给了我一个JSON 我遵循以下信息:Google maps 如何在IOS和Android上定制/设置Expo中的MapView?,google-maps,react-native,expo,Google Maps,React Native,Expo,我已经在上生成了一个样式,它给了我一个JSON 我遵循以下信息: 由于某些原因,样式设置不起作用。在IOS上,默认情况下,打开的不是谷歌地图解决方案:您需要向MapView添加以下属性:provider={MapView.provider\u GOOGLE} 在安卓系统上,它应该马上就能工作 以下是一个工作示例: import React from "react"; import { StyleSheet, Text } from "react-native"; import { MapVi
由于某些原因,样式设置不起作用。在IOS上,默认情况下,打开的不是谷歌地图
解决方案:
您需要向MapView添加以下属性:
provider={MapView.provider\u GOOGLE}
在安卓系统上,它应该马上就能工作
以下是一个工作示例:
import React from "react";
import { StyleSheet, Text } from "react-native";
import { MapView, Constants } from 'expo';
export default class MapScreen extends React.Component {
render() {
return (
<MapView
style = { styles.container }
provider = { MapView.PROVIDER_GOOGLE }
customMapStyle = { generatedMapStyle }
/>
);}
}
const styles = StyleSheet.create({
container: {
flex: 1,
}
});
const generatedMapStyle = [...] // just paste the JSON here.
从“React”导入React;
从“react native”导入{StyleSheet,Text};
从“expo”导入{MapView,Constants};
导出默认类MapScreen扩展React.Component{
render(){
返回(
);}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
}
});
const generatedMapStyle=[…]//只需将JSON粘贴到此处即可。
在IOS上,默认情况下,打开的不是谷歌地图解决方案:
您需要向MapView添加以下属性:
provider={MapView.provider\u GOOGLE}
在安卓系统上,它应该马上就能工作
以下是一个工作示例:
import React from "react";
import { StyleSheet, Text } from "react-native";
import { MapView, Constants } from 'expo';
export default class MapScreen extends React.Component {
render() {
return (
<MapView
style = { styles.container }
provider = { MapView.PROVIDER_GOOGLE }
customMapStyle = { generatedMapStyle }
/>
);}
}
const styles = StyleSheet.create({
container: {
flex: 1,
}
});
const generatedMapStyle = [...] // just paste the JSON here.
从“React”导入React;
从“react native”导入{StyleSheet,Text};
从“expo”导入{MapView,Constants};
导出默认类MapScreen扩展React.Component{
render(){
返回(
);}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
}
});
const generatedMapStyle=[…]//只需将JSON粘贴到此处即可。
此外,请确保已在谷歌云平台中启用了适用于iOS/Android服务的地图SDK,并在app.json中包含API密钥。我花了4次构建才发现……此外,请确保您已在谷歌云平台中启用了iOS/Android服务的地图SDK,并在app.json中包含API密钥。我花了4次构建才发现……请确保在app.json文件中包含google maps api密钥。该应用程序在构建时将在iOS上崩溃,在testflight/iOS Store上确保在app.json文件中包含google maps api密钥。该应用程序在构建时会在iOS上崩溃,并在testflight/iOS应用商店上崩溃