export function mapBound(city, map, maskFlag) {
  console.log("city", city);
  var district = new AMap.DistrictSearch({
    extensions: "all", // 返回行政区边界坐标等具体信息
    level: "district", // 设置查询行政区级别为 区
  });
  district.search(city, (status, result) => {
    if (status === 'complete' && result.info === 'OK') {
      var bounds = result.districtList[0].boundaries;
      if (bounds) {
        bounds.forEach(boundary => {
          new AMap.Polyline({
            map: map,
            strokeWeight: 2,
            strokeColor: "#09f",
            strokeStyle: "dashed",
            path: boundary,
          });
        });

        if (maskFlag) {
          let mask = new AMap.Polygon({
            path: bounds[0], // 边界坐标点集合
            strokeStyle: "dashed",
            strokeWeight: 0, // 边框宽度，设为 0 表示没有边框
            zIndex: 100, // 显示优先级，越大越靠上层
          });

          // 添加遮罩层到地图
          map.add(mask);
        }
      }
    } else {
      console.error('Failed to search district:', result.info);
    }
  });
}
