I am having an issue where I am using variables for a few properties in a GeoJSON object that is being created by looping through a data set.
The issue is that when I use the variable LongLat which contains -117.68584, 33.47016 verified by console.log(); I get an error leaflet.js:5 Uncaught (in promise) Error: Invalid LatLng object: (undefined, -117.68584, 33.47016)
I don't understand why the undefined is there. If I hard code the coordinates into the GeoJSON the code works, except obviously not as desired since all points have the same location.
Below is the section of code where the problem is occurring.
for (var i = 0; i < data.length; i++) {
var unit = data[i];
var relationship = unit.relationship;
var Lat = unit.Lat;
var Long = unit.Long;
var LatLong = Lat + ", " + Long;
var LongLat = Long + ", " + Lat;
var name = unit.name;
var ID = unit.ID;
switch (relationship) {
case "Friend":
var friendGeoData = {
type: "FeatureCollection",
features: [
{
geometry: {
type: "Point",
coordinates: [LongLat],
},
type: "Feature",
properties: {
popupContent: LatLong,
},
id: ID,
},
],
};
/* snip */
}
}