Ion.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Credit from './Credit.js';
  2. import defined from './defined.js';
  3. import Resource from './Resource.js';
  4. var defaultTokenCredit;
  5. var defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYmY1OGY2NS1kODVmLTQxNTUtOWY5YS00ODE1Y2E1ZjFkZTQiLCJpZCI6MjU5LCJzY29wZXMiOlsiYXNyIiwiZ2MiXSwiaWF0IjoxNTcyNjI4NjQ5fQ.CYr8wbSJnOsWz4x2ufDHVe7CGvWzEWl4HzcOcceaNCE';
  6. /**
  7. * Default settings for accessing the Cesium ion API.
  8. * @exports Ion
  9. *
  10. * An ion access token is only required if you are using any ion related APIs.
  11. * A default access token is provided for evaluation purposes only.
  12. * Sign up for a free ion account and get your own access token at {@link https://cesium.com}
  13. *
  14. * @see IonResource
  15. * @see IonImageryProvider
  16. * @see IonGeocoderService
  17. * @see createWorldImagery
  18. * @see createWorldTerrain
  19. */
  20. var Ion = {};
  21. /**
  22. * Gets or sets the default Cesium ion access token.
  23. *
  24. * @type {String}
  25. */
  26. Ion.defaultAccessToken = defaultAccessToken;
  27. /**
  28. * Gets or sets the default Cesium ion server.
  29. *
  30. * @type {String|Resource}
  31. * @default https://api.cesium.com
  32. */
  33. Ion.defaultServer = new Resource({ url: 'https://api.cesium.com/' });
  34. Ion.getDefaultTokenCredit = function(providedKey) {
  35. if (providedKey !== defaultAccessToken) {
  36. return undefined;
  37. }
  38. if (!defined(defaultTokenCredit)) {
  39. var defaultTokenMessage = '<b> \
  40. This application is using Cesium\'s default ion access token. Please assign <i>Cesium.Ion.defaultAccessToken</i> \
  41. with an access token from your ion account before making any Cesium API calls. \
  42. You can sign up for a free ion account at <a href="https://cesium.com">https://cesium.com</a>.</b>';
  43. defaultTokenCredit = new Credit(defaultTokenMessage, true);
  44. }
  45. return defaultTokenCredit;
  46. };
  47. export default Ion;