function layerQuery(objectId) {
const featureLayer = view.map.layers.getItemAt(0);
const queryParams = featureLayer.createQuery();
queryParams.where = "objectid=" + objectId;
queryParams.outFields = ["x", "y", "z"];
featureLayer.queryFeatures(queryParams).then(function (results) {
const coords = results.features[0].attributes;
direction_lookup(Promise, Promise,coords.x,coords.y)
});
const objectIdNext = objectId + 1
const queryParamsTb = featureLayer.createQuery();
queryParamsTb.where = "objectid=" + objectIdNext;
queryParamsTb.outFields = ["x", "y", "z"];
featureLayer.queryFeatures(queryParamsTb).then(function (results) {
var coordstb = results.features[0].attributes;
direction_lookup(coordstb.x, coordstb.y,Promise,Promise)
});
//console.log(coordstb.x)
}
I want to send the four parameters we obtained as a result of the above two functions to the following function.
function direction_lookup(destination_x, origin_x, destination_y, origin_y) {
var compass_brackets, compass_lookup, degrees_final, degrees_temp, deltaX, deltaY;
deltaX = destination_x - origin_x;
deltaY = destination_y - origin_y;
degrees_temp = Math.atan2(deltaX, deltaY) / Math.PI * 180;
if (degrees_temp < 0) {
degrees_final = 360 + degrees_temp;
} else {
degrees_final = degrees_temp;
}
compass_brackets = ["N", "NE", "E", "SE", "S", "SW", "W", "NW", "N"];
compass_lookup = Math.round(degrees_final / 45);
return [compass_brackets[compass_lookup], degrees_final];
}
console.log(direction_lookup(destination_x, origin_x, destination_y, origin_y));
The 'direction lookup' function takes four parameters. I want to send these four parameters two by two from different functions. can i do this