将国家视图添加到 react-native-maps

Adding a country-view to react-native-maps

您好 - 我正在尝试向 "react-native-map" 添加一个按国家/地区分类的视图,以便 return 按国家/地区分类的数据;而不是只有 markers/custom 标记。有谁知道这样做的方法吗?

上图类似于我想要实现的,它使用了 mapbox,如果不从 Expo 中弹出,它在 ReactNative 上不完全可用。

我已经在寻找现有的图块或预制图块 'shapes' 以覆盖在 react-native-maps 上。我为美国各州找到了一些,但没有为个别国家找到。使用 Google 作为 'provider' 并使用 'customMapStyle' 似乎也无法解决问题。

<MapView
        provider={PROVIDER_GOOGLE} 
        customMapStyle={mapJson} 
        style={{
          alignSelf: 'stretch',
          height: '100%',
          width: '100%',
          justifyContent: 'center',
          alignItems: 'center',
          position: 'absolute',
          top: 0,
        }}
        initialRegion={region}
      >

尝试获取要突出显示的国家/地区的 geojson 并在 MapView.

中添加一个 geojson 标签
<MapView
  provider={PROVIDER_GOOGLE} // remove if not using Google Maps
  style={mapStyles.map}
  zoomEnabled
  region={{
    latitude: parseFloat(coOrdinates.lat),
    longitude: parseFloat(coOrdinates.lng),
    latitudeDelta: 30,
    longitudeDelta: 30,
  }}>

  <Geojson
    geojson={features} // geojson of the countries you want to highlight
    strokeColor="#FF6D6A"
    fillColor="#FF6D6A"
    strokeWidth={2}
  />

</MapView>