import XYZ from 'ol/source/XYZ'

class Google extends XYZ {
    constructor(options = {}) {
        const projection = options['projection'] || 'EPSG:3857'
        const crossOrigin = options.crossOrigin || 'anonymous'
        const url = options.url || 'http://www.google.cn/maps/vt?lyrs=m@189&gl=cn&x={x}&y={y}&z={z}'
        super({
            projection,
            cacheSize: options.cacheSize,
            crossOrigin: crossOrigin,
            opaque: options.opaque !== undefined ? options.opaque : true,
            maxZoom: options.maxZoom !== undefined ? options.maxZoom : 19,
            reprojectionErrorThreshold: options.reprojectionErrorThreshold,
            tileLoadFunction: options.tileLoadFunction,
            url: url,
            wrapX: options.wrapX
        })
    }
}

export default Google