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.

index.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. @Author: Caven Chen
  3. **/
  4. import { setParam, registerLib } from './global-api'
  5. import { registerEcharts } from './modules/chart'
  6. const DEF_BASE_URL = './libs/dc-sdk/resources/'
  7. let _baseUrl = DEF_BASE_URL
  8. let __isInitialized = false
  9. export { registerLib, getLib } from './global-api'
  10. export * from './modules'
  11. export * from './modules/third-part'
  12. export { Math } from './modules/math'
  13. export { ChartLayer } from './modules/chart'
  14. export const config = {
  15. set baseUrl(baseUrl) {
  16. _baseUrl = baseUrl
  17. },
  18. get baseUrl() {
  19. return _baseUrl
  20. },
  21. }
  22. export function ready(options = {}) {
  23. if (__isInitialized) {
  24. return Promise.resolve()
  25. }
  26. __cmdOut && __cmdOut()
  27. return new Promise((resolve, reject) => {
  28. //reset CESIUM_BASE_URL
  29. if (options['baseUrl']) {
  30. config.baseUrl = options['baseUrl']
  31. }
  32. //register echarts lib
  33. if (options['echarts']) {
  34. registerEcharts(options['echarts'])
  35. registerLib('echarts', options['echarts'])
  36. }
  37. //register echarts lib
  38. if (options['turf']) {
  39. registerLib('turf', options['turf'])
  40. }
  41. __isInitialized = true
  42. setParam('isInitialized', true)
  43. setParam('baseUrl', this.config.baseUrl)
  44. resolve()
  45. }).catch((e) => {
  46. throw new Error(e.message)
  47. })
  48. }