declare namespace AMap {
  namespace MarkerClusterer {
    interface Style {
      url: string
      size: Size
      offset?: Pixel
      imageOffset?: Pixel
      textColor?: string
      textSize?: number
    }

    interface Context {
      count: number
      markers: Marker[]
      marker: Marker
    }

    interface Options {
      gridSize?: number
      minClusterSize?: number
      maxZoom?: number
      averageCenter?: boolean
      zoomOnClick?: boolean
      styles?: Style[]
      renderClusterMarker?: (context: Context) => void
    }
  }

  interface MarkerClusterer extends Tool {
    new (
      map: Map,
      markers: Marker[],
      options?: MarkerClusterer.Options
    ): MarkerClusterer

    addMarker(marker: Marker): void
    removeMarker(marker: Marker): void
    getClustersCount(): number
    getGridSize(): number
    getMaxZoom(): number
    getMinClusterSize(): number
    isAverageCenter(): boolean
    getStyles(): MarkerClusterer.Style[]
    getMarkers(): Marker[]

    setMap(map: Map): void
    setGridSize(size: number): void
    setMaxZoom(zoom: number): void
    setMinClusterSize(size: number): void
    setAverageCenter(averageCenter: boolean): void
    setStyles(styles: MarkerClusterer.Style[]): void
    setMarkers(markers: Marker[]): Map
    clearMarkers(): void
    addMarkers(markers: Marker[]): void
    removeMarkers(markers: Marker[]): void
  }
}
