import TiledLayer from './TiledLayer' ; import LabelLayer from './LabelLayer' ; import { devicePixelRatio } from '../Env' ; type Style = "Default" | "Satellite" | "Road" | "RoadOnly" | "Terrain" | "TerrainOnly" ; const scale = devicePixelRatio > 1 ? 2 : 1 ; export class GoogleTiledLayer extends TiledLayer { private idx : number = 0 ; constructor ( style = "Default" ) { super ( style ) ; } getTileUrl ( level , row , column ) { if ( this . idx === undefined ) { this . idx = 0 ; } var lyrs = "y" ; switch ( this . style ) { case "Satellite" : lyrs = "s" ; break ; case "Road" : lyrs = "m" ; break ; case "RoadOnly" : lyrs = "h" ; break ; case "Terrain" : lyrs = "p" ; break ; case "TerrainOnly" : lyrs = "t" ; break ; } var url = `//mt${ this . idx }.google.cn/maps/vt?lyrs=${ lyrs }&hl=zh-CN&gl=CN&&x=${ column }&y=${ row }&z=${ level }&scale=${ scale }` ; this . idx ++ ; if ( this . idx >= 4 ) { this . idx = 0 ; } return url ; } } ; export class GoogleLabelLayer extends LabelLayer { private idx : number = 0 ; getTileUrl ( level , row , column ) { if ( this . idx === undefined ) { this . idx = 0 ; } var url = `//mt${ this . idx }.google.cn/vt/imgtp=png32&lyrs=h@365000000&hl=zh-CN&gl=cn&x=${ column }&y=${ row }&z=${ level }&s=Galil` ; this . idx ++ ; if ( this . idx >= 4 ) { this . idx = 0 ; } return url ; } } ;