Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从数组列表中绘制多段线?_Javascript_Reactjs_React Native_React Native Android_React Native Maps - Fatal编程技术网

Javascript 如何从数组列表中绘制多段线?

Javascript 如何从数组列表中绘制多段线?,javascript,reactjs,react-native,react-native-android,react-native-maps,Javascript,Reactjs,React Native,React Native Android,React Native Maps,我已经开始使用地图上的数组坐标绘制多段线,但运气不佳 我不确定我是否正确地传递了坐标数组 以下是渲染多段线的方式: 下面是包含coords的api链接: 我有这样的代码 <MapView style={styles.mapStyle} provider={PROVIDER_GOOGLE} minZoomLevel={0} showsTraffic={false} sho

我已经开始使用地图上的数组坐标绘制多段线,但运气不佳

我不确定我是否正确地传递了坐标数组

以下是渲染多段线的方式:

下面是包含coords的api链接:

我有这样的代码

 <MapView
            style={styles.mapStyle}
            provider={PROVIDER_GOOGLE}
            minZoomLevel={0}
            showsTraffic={false}
            showsBuildings={true}
            followUserLocation={false}
            loadingEnabled={true}
            showsUserLocation={true}
            loadingIndicatorColor={'green'}
            initialRegion={{
              latitude: 37.78825,
              longitude: -122.4324,
              latitudeDelta: 0.0922,
              longitudeDelta: 0.0421,
            }}
            zoomEnabled={true}
            showsUserLocation={true}>
              {
                
                
              speed.map((d) =>
              d.segments.map((c) => (
                <Polyline
                  coordinates={c.coordinate}
                  strokeColor="#000" the map-provider
         
                  strokeWidth={6}>
                  <Marker
                    coordinate={{latitude: 37.8025259, longitude: -122.4351431}}
                    title="Flatiron School Atlanta"
                    description="This is where the magic happens!"></Marker>
                </Polyline>
              )),
            )}
          </MapView>
感谢您的帮助

坐标是一个LatLng数组

键入LatLng{纬度:数字,经度:数字,}

因此,类似这样的方法应该有效:

d.segments.map((c) => 
    <Polyline
      coordinates={c.coordinates.map(c => ({latitude: c[0], longitude: c[1]}))}
      strokeColor="#000"
      strokeWidth={6}>
    </Polyline>
)
d.segments.map((c)=>
({纬度:c[0],经度:c[1]})
strokeColor=“#000”
冲程宽度={6}>
)
d.segments.map((c) => 
    <Polyline
      coordinates={c.coordinates.map(c => ({latitude: c[0], longitude: c[1]}))}
      strokeColor="#000"
      strokeWidth={6}>
    </Polyline>
)