You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TencentImageryProvider.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @Author: Caven
  3. * @Date: 2020-01-21 18:10:47
  4. */
  5. import { Cesium } from '@dc-modules/namespace'
  6. import ImageryType from '../ImageryType'
  7. const TILE_URL = {
  8. img:
  9. '//p{s}.map.gtimg.com/sateTiles/{z}/{sx}/{sy}/{x}_{reverseY}.jpg?version=400',
  10. elec:
  11. '//rt{s}.map.gtimg.com/tile?z={z}&x={x}&y={reverseY}&styleid={style}&scene=0&version=347'
  12. }
  13. class TencentImageryProvider extends Cesium.UrlTemplateImageryProvider {
  14. constructor(options = {}) {
  15. let url =
  16. options.url ||
  17. [
  18. options.protocol || '',
  19. TILE_URL[options.style] || TILE_URL['elec']
  20. ].join('')
  21. options['url'] = url.replace('{style}', options.style || 1)
  22. options['subdomains'] = options.subdomains || ['1', '2', '3']
  23. if (options.style === 'img') {
  24. options['customTags'] = {
  25. sx: (imageryProvider, x, y, level) => {
  26. return x >> 4
  27. },
  28. sy: (imageryProvider, x, y, level) => {
  29. return ((1 << level) - y) >> 4
  30. }
  31. }
  32. }
  33. super(options)
  34. }
  35. }
  36. ImageryType.TENCENT = 'tencent'
  37. export default TencentImageryProvider