import { MapType } from "../lib/mapType";

export type Config = L.TileLayerOptions & { urlTemplate: string, center: L.LatLngExpression, zoomSnap?: number }

const mapConfig: Record<MapType, Config> = {
    baidu: {
        urlTemplate: "http://localhost/baidumaps/roadmap/{z}/{x}/{y}.png",
        errorTileUrl: 'http://localhost/baidumaps/roadmap/error.png',
        center: [39.926474, 116.403283],
        maxZoom: 15, minZoom: 3
    },
    gaode: {
        urlTemplate: "http://localhost/mapabc/roadmap/{z}/{x}/{y}.png",
        errorTileUrl: 'http://localhost/baidumaps/roadmap/error.png',
        center: [-97.00238024827533, 210.7725501856634],
        maxZoom: 15, minZoom: 3
    },
    gaodeLine: {
        urlTemplate: "http://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
        errorTileUrl: 'http://localhost/baidumaps/roadmap/error.png',
        center: [-97.00238024827533, 210.7725501856634],
        maxZoom: 15, minZoom: 3
    }
}

function useConfig(): (name: MapType) => Config {
    return (name) => mapConfig[name]
}


export default useConfig
