// eslint-disable-next-line import/extensions
import arcgisConfig from '@arcgis/core/config';
import React from 'react';
// eslint-disable-next-line import/extensions
import { ArcGISMap as MapComponent } from '@wisdom-map/arcgismap';
// import MapComponent from './lib/index.js';
// eslint-disable-next-line import/no-unresolved
import pkg from '../../../../package.json';
arcgisConfig.assetsPath = `${
  window.location.origin
}/${pkg.name.toLocaleLowerCase()}/assets`;

// eslint-disable-next-line react/prefer-stateless-function
export default class ArcGISMap extends React.Component {
  destroyAMap() {
    const mapKey = [
      '_AMap_AMap.MapType',
      '_AMap_labelcanvas',
      '_AMap_imagelayer',
      '_AMap_anole',
      '_AMap_AMap.Scale',
      '_AMap_rbush',
      '_AMap_AMap.IndoorMap',
      '_AMap_AMap.CustomLayer',
      '_AMap_AMap.MarkerClusterer',
      '_AMap_vectorlayer',
      '_AMap_AMap.OverView',
      '_AMap_sync',
      '_AMap_AMap.PlaceSearch',
      '_AMap_AMap.DistrictSearch',
      '_AMap_Map3D',
      '_AMap_AMap.Autocomplete',
      '_AMap_AMap.Heatmap',
      '_AMap_wgl',
      '_AMap_overlay',
      '_AMap_cvector',
      '_AMap_AMap.ToolBar',
      '_AMap_mouse',
      '_AMap_AMap.RangingTool',
      '_AMap_data.tileKeys'
    ];
    // eslint-disable-next-line no-plusplus
    for (let i = 0; i < mapKey.length; i++) {
      localStorage.removeItem(mapKey[i]);
    }
    delete window.AMap;
    delete window.AMapUI;
    delete window.AMapUI_DEBUG;
  }
  componentWillMount() {
    this.destroyAMap()
  }

  render() {
    // this.destroyAMap();
    return (
      <MapComponent {...this.props} assetsPath={arcgisConfig.assetsPath} />
    );
  }
}
