interface flexObj {
  url: string;
  opacity: number;
  zIndex: number;
  zooms: number[];
}
const loadFlex = function (mapinstance: any, option: flexObj) {
  return new mapinstance.AMap.TileLayer.Flexible({
    map: mapinstance.map,
    opacity: option.opacity,
    zooms: option.zooms,
    createTile: function (x, y, z, success, fail) {
      const img = document.createElement('img');
      img.onload = function () {
        success(img);
      };
      img.onerror = function () {
        fail();
      };
      img.src = option.url + z + '/' + y + '/' + x + '.png';
      img.crossOrigin = 'anonymous';
    },
  });
};
export default loadFlex;
