SOURCE

/**
 * 查询院落面
 */
export async function queryYLM(smid: string) {
  const param = new L.supermap.QueryBySQLParameters({
    queryParams: {
      name: 'sp_bz_address_ylm_a@standard_address_bz.4',
      attributeFilter: `smid = ${smid}`,
    },
  });
  return new Promise((resolve, reject) => {
    new L.supermap.QueryService(YLM_LAYER).queryBySQL(param, function (serviceResult) {
      resolve(serviceResult.result);
    });
  });
}

// 上一个高亮的院落面
let lastHighlightYLM: any = null;
/**
 * 高亮院落面
 */
export async function highlightYLM(smid, map) {
  clearHighlightYLM(map);
  const result = (await queryYLM(smid)) as any;
  lastHighlightYLM = L.geoJSON(result.recordsets[0].features, {
    style: function () {
      return { color: '#4197e8', fillColor: '#96cbfa', fillOpacity: 0.5 };
    },
  }).addTo(map);
}

export function clearHighlightYLM(map) {
  if (lastHighlightYLM) {
    map.removeLayer(lastHighlightYLM);
    lastHighlightYLM = null;
  }
}
console 命令行工具 X clear

                    
>
console