import Utils from '../Utils' ; import TiledLayer from './TiledLayer' ; import TrafficLayer from './TrafficLayer' ; import LabelLayer from './LabelLayer' ; export class SosoTiledLayer extends TiledLayer { getTileUrl ( level , row , column ) { if ( level >= 10 ) { return this . _getPoliticalUrl ( level , row , column ) ; } return this . _getImageUrl ( level , row , column ) ; } private _getDemUrl ( level , row , column ) { var tileCount = Math . pow ( 2 , level ) ; var a = column ; var b = tileCount - row - 1 ; var A = Math . floor ( a / 16 ) ; var B = Math . floor ( b / 16 ) ; var sum = level + row + column ; var serverIdx = sum % 4 ; var url = `//p${ serverIdx }.map.gtimg.com/demTiles/${ level }/${ A }/${ B }/${ a }_${ b }.jpg` ; return url ; } private _getImageUrl ( level , row , column ) { var tileCount = Math . pow ( 2 , level ) ; var a = column ; var b = tileCount - row - 1 ; var A = Math . floor ( a / 16 ) ; var B = Math . floor ( b / 16 ) ; var sum = level + row + column ; var serverIdx = sum % 4 ; var url = `//p${ serverIdx }.map.gtimg.com/sateTiles/${ level }/${ A }/${ B }/${ a }_${ b }.jpg?version=101` ; return url ; } private _getPoliticalUrl ( level , row , column ) { row = Math . pow ( 2 , level ) - row - 1 ; var index = ( level + row + column ) % 4 ; var url = `//rt${ index }.map.gtimg.com/tile?z=${ level }&x=${ column }&y=${ row }&type=vector&styleid=3&version=112` ; return this . wrapUrlWithProxy ( url ) ; } } ; export class SosoTrafficLayer extends TrafficLayer { private idx : number = 1 ; private readonly domains : string [ ] = [ "rtt2" , "rtt2a" , "rtt2b" , "rtt2c" ] ; protected minLevel : number = 11 ; getTileUrl ( level , row , column ) { if ( this . idx === undefined ) { this . idx = 0 ; } row = Math . pow ( 2 , level ) - row - 1 ; var timestamp = Math . floor ( Date . now ( ) / 10000 ) ; var url = `//${ this . domains [ this . idx ] }.map.qq.com/rtt/?z=${ level }&x=${ column }&y=${ row }&timeKey${ timestamp }` ; this . idx ++ ; if ( this . idx >= 4 ) { this . idx = 0 ; } return Utils . wrapUrlWithProxy ( url ) ; } } ; export class SosoLabelLayer extends LabelLayer { private idx : number = 0 ; getTileUrl ( level , row , column ) { if ( this . idx === undefined ) { this . idx = 0 ; } row = Math . pow ( 2 , level ) - row - 1 ; const url = `//rt${ this . idx }.map.gtimg.com/tile?z=${ level }&x=${ column }&y=${ row }&type=vector&styleid=3&version=224` ; this . idx ++ ; if ( this . idx >= 4 ) { this . idx = 0 ; } return url ; } } ;