【问题标题】:React-native-maps fill regions with different colorsReact-native-maps 用不同颜色填充区域
【发布时间】:2021-11-09 07:54:14
【问题描述】:

我使用react-native-maps 作为地图库。有没有办法用不同的颜色填充区域?我有从 Internet 下载的国家/地区的 geojson,并将其放入 <Geojson> 组件中。

<MapView
   style={styles.map}
   zoomEnabled
   provider={PROVIDER_GOOGLE}
 >
      <Geojson 
         fillColor="red"
         geojson={geojson}
      />
</MapView>

这是我收到的。

同样的问题:react-native-maps fill color to each region

【问题讨论】:

    标签: reactjs react-native google-maps geojson react-native-maps


    【解决方案1】:

    可以使用多个&lt;Geojson /&gt; 组件并为它们设置不同的fillColor prop。类似的东西。

    {geojson.features.map(feature => {
       const insertedObject = {
           features: [feature]
       };
    
       if (feature.id === 'AGO' ||feature.id === 'AFG' || feature.id === 'RUS') {
            return <Geojson 
                      geojson={insertedObject}
                      fillColor={'orange'}
                   />
       }
        return <Geojson 
                 geojson={insertedObject}
                 fillColor={'red'}
               />
    })}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-13
      • 2021-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多