MapboxApi.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import defined from "./defined.js";
  2. import deprecationWarning from "./deprecationWarning.js";
  3. var defaultAccessToken;
  4. /**
  5. * @namespace MapboxApi
  6. */
  7. var MapboxApi = {};
  8. Object.defineProperties(MapboxApi, {
  9. /**
  10. * The default Mapbox API access token to use if one is not provided to the
  11. * constructor of an object that uses the Mapbox API. If this property is undefined,
  12. * Cesium's default access token is used, which is only suitable for use early in development.
  13. * Please supply your own access token as soon as possible and prior to deployment.
  14. * Visit {@link https://www.mapbox.com/help/create-api-access-token/} for details.
  15. * When Cesium's default access token is used, a message is printed to the console the first
  16. * time the Mapbox API is used.
  17. *
  18. * @type {String}
  19. * @memberof MapboxApi
  20. * @deprecated
  21. */
  22. defaultAccessToken: {
  23. set: function (value) {
  24. defaultAccessToken = value;
  25. deprecationWarning(
  26. "mapbox-token",
  27. "MapboxApi.defaultAccessToken is deprecated and will be removed in CesiumJS 1.73. Pass your access token directly to the MapboxImageryProvider or MapboxStyleImageryProvider constructors."
  28. );
  29. },
  30. get: function () {
  31. return defaultAccessToken;
  32. },
  33. },
  34. });
  35. MapboxApi.getAccessToken = function (providedToken) {
  36. if (defined(providedToken)) {
  37. return providedToken;
  38. }
  39. return MapboxApi.defaultAccessToken;
  40. };
  41. export default MapboxApi;