utils.js 922 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.parseMarker = void 0;
  4. var util_1 = require("@antv/util");
  5. /**
  6. * 解析marker类型
  7. */
  8. function parseMarker(icon) {
  9. var type = 'default';
  10. if ((0, util_1.isObject)(icon) && icon instanceof Image)
  11. type = 'image';
  12. else if ((0, util_1.isFunction)(icon))
  13. type = 'symbol';
  14. else if ((0, util_1.isString)(icon)) {
  15. var dataURLsPattern = new RegExp('data:(image|text)');
  16. if (icon.match(dataURLsPattern)) {
  17. type = 'base64';
  18. }
  19. else if (/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(icon)) {
  20. type = 'url';
  21. }
  22. else {
  23. // 不然就当作symbol string 处理
  24. type = 'symbol';
  25. }
  26. }
  27. return type;
  28. }
  29. exports.parseMarker = parseMarker;
  30. //# sourceMappingURL=utils.js.map