标记数组未显示在Mapview(Expo)上。需要帮助吗
使用Date.now作为索引的经度和纬度作为键都仍然不起作用。 尝试在地图上使用固定的经度和纬度,从提供的坐标中了解其是否存在,但仍不显示
正在传递数据
const nearByDrivers = [
{
"coordinate": {
"type": "Point",
"coordinates": [
-0.16791,
5.67744
]
},
"online": true,
"socketId": "",
"_id": "5c09433ea3c5ce10b03e8e63",
"driverId": "5c09433ea3c5ce10b03e8e62",
"__v": 0
},
{
"coordinate": {
"type": "Point",
"coordinates": [
-0.14923,
5.646106
]
},
"online": true,
"socketId": "",
"_id": "5c094ac7d92c8f2bd88d6014",
"driverId": "5c094ac6d92c8f2bd88d6013",
"__v": 0
}
]``
我看过stackoverflow上的其他文档,但确实知道为什么它不渲染我可能会丢失一些东西
import React from "react";
import { View } from "native-base";
import { MapView } from "expo";
import styles from "./MapTrackStyles.js";
export const MapTrack = ({
region,
nearByDrivers,
}) => {
return (
<View style={styles.container}>
<MapView
provider={MapView.PROVIDER_GOOGLE}
style={styles.map}
region={region}
>
{nearByDrivers.map((item, index) => {
<MapView.Marker
key={index}
coordinate={{
//latitude: marker.coordinate.coordinates[1],
//longitude: marker.coordinate.coordinates[0]
latitude: 5.67744,
longitude: -0.16791,
}}
pinColor="green"
/>
})
}
</MapView>
</View>
);
};
export default MapTrack;