Sno*_*man 1 google-maps react-native expo
我在https://mapstyle.withgoogle.com上生成了一个样式,它给了我一个 JSON。
我按照这里的信息:https : //github.com/airbnb/react-native-maps
出于某种原因,样式不起作用。
在 IOS 上,默认情况下,打开的不是谷歌地图。
解决方案:
需要在MapView中添加如下属性:provider = { MapView.PROVIDER_GOOGLE }
在 Android 上,它应该可以立即工作。
这是一个工作示例:
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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4769 次 |
| 最近记录: |