import MapboxStyleLayer from "../MapboxStyleLayer";

/**
 * Layer for RailplusLayer
 * Extends {@link https://mobility-toolbox-js.geops.io/doc/class/build/ol/layers/MapboxStyleLayer%20js~MapboxStyleLayer%20html-offset-anchor}
 * @private
 * @class
 * @param {Object} [options] Layer options.
 */
class RailplusLayer extends MapboxStyleLayer {
  constructor() {
    let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    super(options);
    this.abortController = new AbortController();
  }
  onLoad() {
    super.onLoad();
    this.fetchRailplusProviders();
  }
  fetchRailplusProviders() {
    var _this$mapboxLayer, _this$mapboxLayer2;
    this.abortController.abort();
    this.abortController = new AbortController();
    fetch("".concat((_this$mapboxLayer = this.mapboxLayer) === null || _this$mapboxLayer === void 0 ? void 0 : _this$mapboxLayer.url, "/data/ch.railplus.betreiberinnen.json?key=").concat((_this$mapboxLayer2 = this.mapboxLayer) === null || _this$mapboxLayer2 === void 0 ? void 0 : _this$mapboxLayer2.apiKey), {
      signal: this.abortController.signal
    }).then(res => res.json()).then(data => {
      this.railplusProviders = data["geops.railplus.tu_info"];
    })
    // eslint-disable-next-line no-console
    .catch(err => console.error(err));
  }
}
export default RailplusLayer;
//# sourceMappingURL=RailplusLayer.js.map