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

4 lat temu
4 lat temu
4 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. options.protocol ? ':' : '',
  20. TILE_URL[options.style || 'elec']
  21. ].join('')
  22. options['url'] = url.replace('{style}', options.style || 1)
  23. options['subdomains'] = options.subdomains || ['1', '2', '3']
  24. if (options.style === 'img') {
  25. options['customTags'] = {
  26. sx: (imageryProvider, x, y, level) => {
  27. return x >> 4
  28. },
  29. sy: (imageryProvider, x, y, level) => {
  30. return ((1 << level) - y) >> 4
  31. }
  32. }
  33. }
  34. super(options)
  35. }
  36. }
  37. ImageryType.TENCENT = 'tencent'
  38. export default TencentImageryProvider