Javascript 如何从数组列表中绘制多段线?
我已经开始使用地图上的数组坐标绘制多段线,但运气不佳 我不确定我是否正确地传递了坐标数组 以下是渲染多段线的方式: 下面是包含coords的api链接: 我有这样的代码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
<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>
)