index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // polyfills
  2. import './polyfills';
  3. import upperCamelCase from 'uppercamelcase';
  4. // 初始化接口
  5. import {initAMapApiLoader} from './services/injected-amap-api-instance';
  6. // 组建导入
  7. import AMap from './components/amap.vue';
  8. import AMapMarker from './components/amap-marker.vue';
  9. import AMapSearchBox from './components/amap-search-box.vue';
  10. import AMapCircle from './components/amap-circle.vue';
  11. import AMapGroupImage from './components/amap-ground-image.vue';
  12. import AMapInfoWindow from './components/amap-info-window.vue';
  13. import AMapPolyline from './components/amap-polyline.vue';
  14. import AMapPolygon from './components/amap-polygon.vue';
  15. import AMapText from './components/amap-text.vue';
  16. import AMapBezierCurve from './components/amap-bezier-curve.vue';
  17. import AMapCircleMarker from './components/amap-circle-marker.vue';
  18. import AMapEllipse from './components/amap-ellipse.vue';
  19. import AMapRectangle from './components/amap-rectangle.vue';
  20. // managers
  21. import AMapManager from './managers/amap-manager';
  22. import createCustomComponent from './adapter/custom-adapter';
  23. let components = [
  24. AMap,
  25. AMapMarker,
  26. AMapSearchBox,
  27. AMapCircle,
  28. AMapGroupImage,
  29. AMapInfoWindow,
  30. AMapPolygon,
  31. AMapPolyline,
  32. AMapText,
  33. AMapBezierCurve,
  34. AMapCircleMarker,
  35. AMapEllipse,
  36. AMapRectangle
  37. ];
  38. let VueAMap = {
  39. initAMapApiLoader,
  40. AMapManager
  41. };
  42. VueAMap.install = (Vue) => {
  43. if (VueAMap.installed) return;
  44. Vue.config.optionMergeStrategies.deferredReady = Vue.config.optionMergeStrategies.created;
  45. components.map(_component => {
  46. // register component
  47. Vue.component(_component.name, _component);
  48. // component cache
  49. VueAMap[upperCamelCase(_component.name).replace(/^El/, '')] = _component;
  50. });
  51. };
  52. const install = function(Vue, opts = {}) {
  53. /* istanbul ignore if */
  54. if (install.installed) return;
  55. VueAMap.install(Vue);
  56. };
  57. /* istanbul ignore if */
  58. if (typeof window !== 'undefined' && window.Vue) {
  59. install(window.Vue);
  60. };
  61. export default VueAMap;
  62. export {
  63. AMapManager,
  64. initAMapApiLoader,
  65. createCustomComponent
  66. };
  67. export { lazyAMapApiLoaderInstance } from './services/injected-amap-api-instance';