Skip to content

Commit

Permalink
only wait for map load if polygon filters not loaded yet
Browse files Browse the repository at this point in the history
  • Loading branch information
zandre-eng committed Dec 19, 2024
1 parent 1d8fc89 commit 8499f2a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions corehq/apps/geospatial/static/geospatial/js/case_management.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ hqDefine("geospatial/js/case_management", [
}
}

function beforeLoadCases(caseData) {
loadCases(caseData);
if (mapModel.hasDisbursementLayer()) {
mapModel.removeDisbursementLayer();
}
}

function loadCases(caseData) {
mapModel.removeItemTypeFromSource('case');
mapModel.caseMapItems([]);
Expand Down Expand Up @@ -516,12 +523,13 @@ hqDefine("geospatial/js/case_management", [
);
}
} else if (xhr.responseJSON.aaData.length && mapModel.mapInstance) {
mapModel.mapInstance.on('load', () => {
loadCases(xhr.responseJSON.aaData);
if (mapModel.hasDisbursementLayer()) {
mapModel.removeDisbursementLayer();
}
});
if (polygonFilterModel) {
beforeLoadCases(xhr.responseJSON.aaData);
} else {
mapModel.mapInstance.on('load', () => {
beforeLoadCases(xhr.responseJSON.aaData);
});
}
}
});
});

0 comments on commit 8499f2a

Please sign in to comment.