I'm trying to create a polygon on selected country using lat and lng from geojson, as geojson stores data in lng and lat and leaflet expects data in lat and lng I'm trying to swap it using the coordstolatlng function but it does not works.
const latlng= L.geoJSON(polygonCountry.geometry, {
coordsToLatLng: function (coordinates) {
// latitude , longitude, altitude
//return new L.LatLng(coords[1], coords[0], coords[2]); //Normal behavior
console.log(coordinates);
return new L.LatLng(coordinates[0], coordinates[1]);
}
});
console.log(latlng);
I'm getting the array of coordinates in console.log(coordinates). But not getting those arrays in console.log(latlng) as it is not returning the corrected array.