Array of markers do not display on Mapview(Expo). would need help on it please

Have used the index and lattitude with Date.now as key all still not working. Have tried using a fixed longitude and latitude on map to know whether its from the coordinates provided but it still doesnt show up

data being passed

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
    }
]``

Ive looked at the other docs at stackoverflow but doent know why it doestnt render i might be missing something

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;

0 Answers