util.js 751 B

123456789101112131415161718192021222324252627282930
  1. import { createPoint } from './factory'
  2. export const isPoint = obj => obj.lng && obj.lat
  3. export const checkType = val => Object.prototype.toString.call(val).slice(8, -1)
  4. export const getPosition = (BMap, point) => isPoint(point) ? createPoint(BMap, point) : point
  5. export const deleteEmptyKey = (obj) => {
  6. Object.keys(obj).forEach(key => {
  7. if (typeof obj[key] === 'undefined') {
  8. delete obj[key];
  9. }
  10. });
  11. }
  12. let config = {
  13. v: '3.0',
  14. type: 'API'
  15. };
  16. export const setConfig = (options = {}) => {
  17. config = Object.assign(config, options);
  18. if (!config.ak) {
  19. console.error('请配置ak:百度地图开发者平台申请的密钥');
  20. }
  21. };
  22. export const getConfig = () => {
  23. return config;
  24. };