【问题标题】:Adding a country-view to react-native-maps向 react-native-maps 添加国家视图
【发布时间】:2019-09-17 11:09:39
【问题描述】:

您好 - 我正在尝试向“react-native-map”添加按国家/地区视图,以便按国家/地区返回数据;而不是只有标记/自定义标记。有人知道这样做的方法吗?

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

我一直在寻找现有的瓷砖或预先形成的“形状”以覆盖在 react-native-maps 上。我为美国各州找到了一些,但没有为个别国家找到。使用谷歌作为“提供者”并拥有“customMapStyle”似乎也不能解决这个问题。

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

【问题讨论】:

    标签: react-native maps customization react-native-maps


    【解决方案1】:

    尝试获取您要突出显示的国家/地区的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>
    

    【讨论】:

    猜你喜欢
    • 2022-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-23
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多