utils.js 776 B

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