Hello!
I was wondering if it would be possible to turn a 2d array of latitude and longitude into a featurelayer? Would this be difficult to accomplish? This is what the data looks like:
var data = [
{ "latitude": 59.441193, "longitude": 24.729494 },
{ "latitude": 59.432365, "longitude": 24.742992 },
{ "latitude": 59.431602, "longitude": 24.757563 },
{ "latitude": 59.437843, "longitude": 24.765759 },
{ "latitude": 59.439644, "longitude": 24.779041 },
{ "latitude": 59.434776, "longitude": 24.756681 }
];
You can iterate over the array and add them to the source of the FeatureLayer.
const data = [
{ latitude: 59.441193, longitude: 24.729494 },
{ latitude: 59.432365, longitude: 24.742992 },
{ latitude: 59.431602, longitude: 24.757563 },
{ latitude: 59.437843, longitude: 24.765759 },
{ latitude: 59.439644, longitude: 24.779041 },
{ latitude: 59.434776, longitude: 24.756681 },
];
const featureLayer = new FeatureLayer({
geometryType: "point",
objectIdField: "OBJECTID",
source: data.map((a) => ({
geometry: {
type: "point",
...a,
},
})),
});