优化queryFeaturesByIds ID 处理逻辑,确保查询功能正常

This commit is contained in:
2026-04-03 13:58:44 +08:00
parent c484aad1d3
commit 56b4777dbd
2 changed files with 23 additions and 3 deletions
+7 -2
View File
@@ -224,11 +224,16 @@ const queryFeaturesByIds = async (
ids: string[],
layer?: string
): Promise<Feature[]> => {
if (!ids.length) {
const normalizedIds = ids
.map((id) => String(id).trim())
.filter((id) => id.length > 0);
if (!normalizedIds.length) {
return [];
}
const orFilter = ids.map((id) => `id='${id}'`).join(" OR ");
const escapedIds = normalizedIds.map((id) => id.replace(/'/g, "''"));
const orFilter = escapedIds.map((id) => `id='${id}'`).join(" OR ");
try {
if (!layer) {