反应本机地图折线未显示

react native map polyline is not showing

这是我的代码。


<View style={styles.map}>
        <MapView
          style={styles.map}
          initialRegion={this.state.region}
          onRegionChangeComplete={this.onRegionChange}
        />
        {
          this.state.allow_set_location ?
            <View style={styles.markerFixed}>
              <Image style={styles.marker} source={marker} />
            </View> : null
        }

        <Polyline
          coordinates={this.state.route_data}
          strokeWidth={1}
          strokeColor="red"
          fillColor="rgba(255,0,0,0.5)"
        />
      </View>

我无法获取折线。 我的 route_data 是对象数组,例如 [{latitude: data, longitude: data}.....]

Polyline 应由 MapView 组件包裹,而不是并排放置。

       <View style={styles.map}>
        <MapView
          style={styles.map}
          initialRegion={this.state.region}
          onRegionChangeComplete={this.onRegionChange}
        >
          <Polyline
            coordinates={this.state.route_data}
            strokeWidth={1}
            strokeColor="red"
            fillColor="rgba(255,0,0,0.5)"
          />
       </MapView>
      </View>