reactjs - 世博地图查看国家颜色
解决方案
我设法找到了解决方案,如果有人有相同的要求,我会在这里解释。我使用了 react-native-maps 和 GeoJson 功能中的 MapView。我也从这里复制了 json 文件:https ://github.com/johan/world.geo.json
- 从 json 文件中复制内容后,将其放在项目中的某个位置(我在 assets/georgia.json 中添加了
转到组件并添加以下代码:
import React, { Component } from 'react'
import { StyleSheet, Dimensions } from 'react-native'
import MapView, {Geojson} from 'react-native-maps';
import myPlace from '../../assets/georgia.json';
export default class DataCoverage extends Component { render() { return ( <MapView style={styles.mapStyle} > <Geojson geojson={myPlace} strokeColor="#0568AE" fillColor="#009FDB" strokeWidth={2} /> </MapView> ); } }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#fff', alignItems: 'center', justifyContent: 'center', }, mapStyle: { width: Dimensions.get('window').width, height: Dimensions.get('window').height, }, })
地图应以您想要的突出显示的国家/地区呈现。
- 如果您想要多个国家/地区,您只需复制“功能”对象并粘贴到您的 json 文件中的全局功能数组中(在我的情况下:georgija.json)。
- 如果您有任何问题,请随时提出。
推荐阅读
- python - 在 Heroku 上存储单行更改文本的方法
- javascript - Javascript箭头函数在其封闭函数中没有得到'this'(React Native)
- javascript - 如何在特定选项卡处于活动状态时打开链接
- python - LookupError:应用程序“层次结构”没有“自定义用户”模型
- c# - 如何从 SQL Server 中找到 WPF 忘记的密码?
- python - 如何将文本输入到远程服务器上的 Python 脚本中?
- javascript - Firebase Auth 在 HTML 的 Form 标签内不起作用
- python - 迭代 Pandas 数据框的最佳方法?
- reactjs - 将项目列表显示为
- vs 作为纯字符串
- python - 在 Pandas 中搜索 df 并在特定字符串之后查找数字