【问题标题】:Polygon fill color not working properly (React Native maps)多边形填充颜色无法正常工作(React Native 贴图)
【发布时间】:2019-09-10 06:24:52
【问题描述】:

我在 iOS 上使用 Google 地图,我有多边形。 (react-native-maps)

更新之前(到版本 0.18.3。-目前我无法更新到最新版本)一切正常,但从现在开始填充颜色会得到奇怪的结果。

有时候颜色可以,有时候不合适,没有规则。

在 android 上一切正常。

export const Polygon = (props) => {
    return (
        <MapView.Polygon
            coordinates={ props.selectedAreas }
            fillColor={ props.fillColor }
            strokeColor={ props.strokeColor }
        />
    )
};

【问题讨论】:

    标签: reactjs google-maps react-native polygon react-native-ios


    【解决方案1】:

    使用来自https://github.com/react-native-community/react-native-maps/issues/3025#issuecomment-538345230 的修复程序为我工作

    import React from 'react';
    import { Polygon } from 'react-native-maps';
    
    function CustomPolygon({ onLayout, ...props }) {
      const ref = React.useRef();
    
      function onLayoutPolygon() {
        if (ref.current) {
          ref.current.setNativeProps({ fillColor: props.fillColor });
        }
        // call onLayout() from the props if you need it
      }
    
      return <Polygon ref={ref} onLayout={onLayoutPolygon} {...props} />;
    }
    
    export default CustomPolygon;
    

    它不是很漂亮,但我想它必须在上游错误修复之前完成。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      • 2017-01-07
      相关资源
      最近更新 更多