0


I have been trying to put marker of the locations , of the user saved in mongodb.

//Get Cordinates from ALL Farms
componentDidMount(){
  const url="http://localhost:5000/api/users/viewFarm/5d3ac84a86688123789e13b2";
  fetch (url,{
      method: "GET"
  }).then(response=> response.json()).then(result=>{
      console.log(result);

     this.setState({
      farmList : result
     }); 
  });
}

The response from backend server for the location of the user

[
    [
        "11.33,22.99"
    ],
    [],
    [
        "11.22,65.33"
    ],
    [
        "32131"
    ],
    [
        "32161"
    ],
    [
        "2"
    ],
    [
        "Location"
    ]
]

Here i can parse the get request and get locations but how to pass the location all the farms in the Leaflet map.

        <Marker position={[23.54474, 87.29164]}>
          <Popup>
            Test Popup
          </Popup>
        </Marker>
2
  • How does you response look like?
    – kboul
    Commented Dec 2, 2019 at 14:49
  • @kboul the response contains locations of the specific user in an array [ [ "11.33,22.99" ], [], [ "11.22,65.33" ], [ "32131" ], [ "32161" ], [ "2" ], [ "Location" ] ]
    – user5140792
    Commented Dec 3, 2019 at 5:59

0