Browse Source

add babel-preset-es2015 support.

windsome.feng 7 years ago
parent
commit
01f540619f
12 changed files with 322 additions and 604 deletions
  1. 2 0
      .npmignore
  2. 6 1
      lib/APILoader.js
  3. 29 16
      lib/Map.js
  4. 27 13
      lib/Marker.js
  5. 27 13
      lib/MassMarks.js
  6. 27 13
      lib/Polygon.js
  7. 27 13
      lib/Polyline.js
  8. 55 37
      lib/api.js
  9. 13 5
      lib/loadScript.js
  10. 27 9
      lib/webservice.js
  11. 4 7
      package.json
  12. 78 477
      yarn.lock

+ 2 - 0
.npmignore

@@ -0,0 +1,2 @@
+.babelrc
+CODE_OF_CONDUCT.md

+ 6 - 1
lib/APILoader.js

@@ -1,3 +1,8 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
 var DEFAULT_CONFIG = {
   v: '1.4.0',
   hostAndPath: 'webapi.amap.com/maps',
@@ -112,4 +117,4 @@ var APILoader = function () {
   return APILoader;
 }();
 
-export default APILoader;
+exports.default = APILoader;

+ 29 - 16
lib/Map.js

@@ -1,12 +1,25 @@
-import React, { Component, PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import { loadMap, createMap, updateMap } from './api';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.Map = undefined;
+
+var _react = require('react');
+
+var _react2 = babelHelpers.interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
+
+var _api = require('./api');
 
 var __com__ = 'Map';
 //const debug = console.log;
 var debug = function debug() {};
 
-export var Map = function (_Component) {
+var Map = exports.Map = function (_Component) {
   babelHelpers.inherits(Map, _Component);
 
   function Map() {
@@ -34,7 +47,7 @@ export var Map = function (_Component) {
           options = _props.options,
           events = _props.events;
 
-      this._entity = createMap(AMap, this.refElement, options, events);
+      this._entity = (0, _api.createMap)(AMap, this.refElement, options, events);
       if (this._entity) {
         if (this.props.refer) this.props.refer(this._entity);
         this.setState({ __map__: this._entity });
@@ -60,7 +73,7 @@ export var Map = function (_Component) {
           events = _props2.events;
 
       if (!this._entity) {
-        this._entity = createMap(AMap, this.refElement, options, events);
+        this._entity = (0, _api.createMap)(AMap, this.refElement, options, events);
         if (this._entity) {
           if (this.props.refer) this.props.refer(this._entity);
           this.setState({ __map__: this._entity });
@@ -69,7 +82,7 @@ export var Map = function (_Component) {
       }
       // need check props changes, then update.
       //updateMap(this._entity, this.props, prevProps);
-      updateMap(this._entity, options, events, prevProps.options, prevProps.events);
+      (0, _api.updateMap)(this._entity, options, events, prevProps.options, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -88,7 +101,7 @@ export var Map = function (_Component) {
   }, {
     key: 'renderChildren',
     value: function renderChildren(children, __map__) {
-      return React.Children.map(children, function (child) {
+      return _react2.default.Children.map(children, function (child) {
         if (child) {
           var cType = child.type;
           /* 针对下面两种组件不注入地图相关属性
@@ -100,7 +113,7 @@ export var Map = function (_Component) {
             return child;
           }
           debug(__com__, 'component renderChildren add __map__');
-          return React.cloneElement(child, {
+          return _react2.default.cloneElement(child, {
             __map__: __map__
           });
         }
@@ -137,7 +150,7 @@ export var Map = function (_Component) {
           staticContext = _props3.staticContext,
           rest = babelHelpers.objectWithoutProperties(_props3, ['AMap', 'options', 'events', 'match', 'location', 'history', 'children', 'staticContext']);
 
-      return React.createElement(
+      return _react2.default.createElement(
         'div',
         babelHelpers.extends({
           ref: function ref(ele) {
@@ -149,13 +162,13 @@ export var Map = function (_Component) {
     }
   }]);
   return Map;
-}(Component);
+}(_react.Component);
 
 Map.propTypes = {
-  AMap: PropTypes.object,
-  refer: PropTypes.func, // 类似ref的函数形式,可以让父组件调用_entity
-  options: PropTypes.object,
-  events: PropTypes.object
+  AMap: _propTypes2.default.object,
+  refer: _propTypes2.default.func, // 类似ref的函数形式,可以让父组件调用_entity
+  options: _propTypes2.default.object,
+  events: _propTypes2.default.object
   //   zoom: PropTypes.number, // 10, //设置地图显示的缩放级别
   //   center: PropTypes.array, // [116.397428, 39.90923],//设置地图中心点坐标
   //   layers: PropTypes.array, // [new AMap.TileLayer.Satellite()],  //设置图层,可设置成包含一个或多个图层的数组
@@ -164,4 +177,4 @@ Map.propTypes = {
   //   lang: PropTypes.string, // 'zh_cn',  //设置地图语言类型
   //   events: PropTypes.object, // {'click': function}, // 事件map
 };
-export default Map;
+exports.default = Map;

+ 27 - 13
lib/Marker.js

@@ -1,11 +1,25 @@
-import React, { Component, PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import { createMarker, updateMarker } from './api';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.Marker = undefined;
+
+var _react = require('react');
+
+var _react2 = babelHelpers.interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
+
+var _api = require('./api');
+
 var __com__ = 'Marker';
 //const debug = console.log;
 var debug = function debug() {};
 
-export var Marker = function (_Component) {
+var Marker = exports.Marker = function (_Component) {
   babelHelpers.inherits(Marker, _Component);
 
   function Marker() {
@@ -37,7 +51,7 @@ export var Marker = function (_Component) {
       //let opts = { ...(options || {}), map: __map__, content: children };
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = createMarker(AMap, opts, events);
+      this._entity = (0, _api.createMarker)(AMap, opts, events);
       if (this._entity) {
         if (this.props.refer) this.props.refer(this._entity);
       }
@@ -66,7 +80,7 @@ export var Marker = function (_Component) {
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = createMarker(AMap, opts, events);
+        this._entity = (0, _api.createMarker)(AMap, opts, events);
         if (this._entity) {
           if (this.props.refer) this.props.refer(this._entity);
         }
@@ -78,7 +92,7 @@ export var Marker = function (_Component) {
         map: prevProps.__map__,
         content: prevProps.children
       });
-      updateMarker(this._entity, opts, events, oldOpts, prevProps.events);
+      (0, _api.updateMarker)(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -129,13 +143,13 @@ export var Marker = function (_Component) {
     }
   }]);
   return Marker;
-}(Component);
+}(_react.Component);
 
 Marker.propTypes = {
-  AMap: PropTypes.object,
-  __map__: PropTypes.object,
-  options: PropTypes.object,
-  events: PropTypes.object
+  AMap: _propTypes2.default.object,
+  __map__: _propTypes2.default.object,
+  options: _propTypes2.default.object,
+  events: _propTypes2.default.object
   //   zoom: PropTypes.number, // 10, //设置地图显示的缩放级别
   //   center: PropTypes.array, // [116.397428, 39.90923],//设置地图中心点坐标
   //   layers: PropTypes.array, // [new AMap.TileLayer.Satellite()],  //设置图层,可设置成包含一个或多个图层的数组
@@ -144,4 +158,4 @@ Marker.propTypes = {
   //   lang: PropTypes.string, // 'zh_cn',  //设置地图语言类型
   //   events: PropTypes.object, // {'click': function}, // 事件map
 };
-export default Marker;
+exports.default = Marker;

+ 27 - 13
lib/MassMarks.js

@@ -1,11 +1,25 @@
-import React, { Component, PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import { createMassMarks, updateMassMarks } from './api';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.MassMarks = undefined;
+
+var _react = require('react');
+
+var _react2 = babelHelpers.interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
+
+var _api = require('./api');
+
 var __com__ = 'MassMarks';
 //const debug = console.log;
 var debug = function debug() {};
 
-export var MassMarks = function (_Component) {
+var MassMarks = exports.MassMarks = function (_Component) {
   babelHelpers.inherits(MassMarks, _Component);
 
   function MassMarks() {
@@ -37,7 +51,7 @@ export var MassMarks = function (_Component) {
       //let opts = { ...(options || {}), map: __map__, content: children };
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = createMassMarks(AMap, opts, events);
+      this._entity = (0, _api.createMassMarks)(AMap, opts, events);
     }
   }, {
     key: 'componentWillReceiveProps',
@@ -63,7 +77,7 @@ export var MassMarks = function (_Component) {
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = createMassMarks(AMap, opts, events);
+        this._entity = (0, _api.createMassMarks)(AMap, opts, events);
         return;
       }
 
@@ -71,7 +85,7 @@ export var MassMarks = function (_Component) {
       var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
         map: prevProps.__map__
       });
-      updateMassMarks(this._entity, opts, events, oldOpts, prevProps.events);
+      (0, _api.updateMassMarks)(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -113,12 +127,12 @@ export var MassMarks = function (_Component) {
     }
   }]);
   return MassMarks;
-}(Component);
+}(_react.Component);
 
 MassMarks.propTypes = {
-  AMap: PropTypes.object,
-  __map__: PropTypes.object,
-  options: PropTypes.object,
-  events: PropTypes.object
+  AMap: _propTypes2.default.object,
+  __map__: _propTypes2.default.object,
+  options: _propTypes2.default.object,
+  events: _propTypes2.default.object
 };
-export default MassMarks;
+exports.default = MassMarks;

+ 27 - 13
lib/Polygon.js

@@ -1,11 +1,25 @@
-import React, { Component, PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import { createPolygon, updatePolygon } from './api';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.Polygon = undefined;
+
+var _react = require('react');
+
+var _react2 = babelHelpers.interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
+
+var _api = require('./api');
+
 var __com__ = 'Polygon';
 //const debug = console.log;
 var debug = function debug() {};
 
-export var Polygon = function (_Component) {
+var Polygon = exports.Polygon = function (_Component) {
   babelHelpers.inherits(Polygon, _Component);
 
   function Polygon() {
@@ -37,7 +51,7 @@ export var Polygon = function (_Component) {
       //let opts = { ...(options || {}), map: __map__, content: children };
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = createPolygon(AMap, opts, events);
+      this._entity = (0, _api.createPolygon)(AMap, opts, events);
     }
   }, {
     key: 'componentWillReceiveProps',
@@ -63,7 +77,7 @@ export var Polygon = function (_Component) {
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = createPolygon(AMap, opts, events);
+        this._entity = (0, _api.createPolygon)(AMap, opts, events);
         return;
       }
 
@@ -71,7 +85,7 @@ export var Polygon = function (_Component) {
       var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
         map: prevProps.__map__
       });
-      updatePolygon(this._entity, opts, events, oldOpts, prevProps.events);
+      (0, _api.updatePolygon)(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -113,12 +127,12 @@ export var Polygon = function (_Component) {
     }
   }]);
   return Polygon;
-}(Component);
+}(_react.Component);
 
 Polygon.propTypes = {
-  AMap: PropTypes.object,
-  __map__: PropTypes.object,
-  options: PropTypes.object,
-  events: PropTypes.object
+  AMap: _propTypes2.default.object,
+  __map__: _propTypes2.default.object,
+  options: _propTypes2.default.object,
+  events: _propTypes2.default.object
 };
-export default Polygon;
+exports.default = Polygon;

+ 27 - 13
lib/Polyline.js

@@ -1,11 +1,25 @@
-import React, { Component, PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import { createPolyline, updatePolyline } from './api';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.Polyline = undefined;
+
+var _react = require('react');
+
+var _react2 = babelHelpers.interopRequireDefault(_react);
+
+var _propTypes = require('prop-types');
+
+var _propTypes2 = babelHelpers.interopRequireDefault(_propTypes);
+
+var _api = require('./api');
+
 var __com__ = 'Polyline';
 //const debug = console.log;
 var debug = function debug() {};
 
-export var Polyline = function (_Component) {
+var Polyline = exports.Polyline = function (_Component) {
   babelHelpers.inherits(Polyline, _Component);
 
   function Polyline() {
@@ -37,7 +51,7 @@ export var Polyline = function (_Component) {
       //let opts = { ...(options || {}), map: __map__, content: children };
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
-      this._entity = createPolyline(AMap, opts, events);
+      this._entity = (0, _api.createPolyline)(AMap, opts, events);
     }
   }, {
     key: 'componentWillReceiveProps',
@@ -63,7 +77,7 @@ export var Polyline = function (_Component) {
 
       var opts = babelHelpers.extends({}, options || {}, { map: __map__ });
       if (!this._entity) {
-        this._entity = createPolyline(AMap, opts, events);
+        this._entity = (0, _api.createPolyline)(AMap, opts, events);
         return;
       }
 
@@ -71,7 +85,7 @@ export var Polyline = function (_Component) {
       var oldOpts = babelHelpers.extends({}, prevProps.options || {}, {
         map: prevProps.__map__
       });
-      updatePolyline(this._entity, opts, events, oldOpts, prevProps.events);
+      (0, _api.updatePolyline)(this._entity, opts, events, oldOpts, prevProps.events);
     }
   }, {
     key: 'componentWillUnmount',
@@ -113,12 +127,12 @@ export var Polyline = function (_Component) {
     }
   }]);
   return Polyline;
-}(Component);
+}(_react.Component);
 
 Polyline.propTypes = {
-  AMap: PropTypes.object,
-  __map__: PropTypes.object,
-  options: PropTypes.object,
-  events: PropTypes.object
+  AMap: _propTypes2.default.object,
+  __map__: _propTypes2.default.object,
+  options: _propTypes2.default.object,
+  events: _propTypes2.default.object
 };
-export default Polyline;
+exports.default = Polyline;

+ 55 - 37
lib/api.js

@@ -1,20 +1,38 @@
-import forOwn from 'lodash/forOwn';
-import isEqual from 'lodash/isEqual';
-import isNil from 'lodash/isNil';
-//import loadjscssfile from './loadScript';
-import APILoader from './APILoader';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.updatePolyline = exports.createPolyline = exports.updatePolygon = exports.createPolygon = exports.updateMassMarks = exports.createMassMarks = exports.updateMarker = exports.createMarker = exports.updateMap = exports.commonUpdate = exports.createMap = exports.loadPlugin = exports.loadMap = exports.loadApi = undefined;
+
+var _forOwn = require('lodash/forOwn');
+
+var _forOwn2 = babelHelpers.interopRequireDefault(_forOwn);
+
+var _isEqual = require('lodash/isEqual');
+
+var _isEqual2 = babelHelpers.interopRequireDefault(_isEqual);
 
-export var loadApi = function loadApi() {
+var _isNil = require('lodash/isNil');
+
+var _isNil2 = babelHelpers.interopRequireDefault(_isNil);
+
+var _APILoader = require('./APILoader');
+
+var _APILoader2 = babelHelpers.interopRequireDefault(_APILoader);
+
+var loadApi = exports.loadApi = function loadApi() {
   var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0325e3d6d69cd56de4980b4f28906fd8';
 
-  return new APILoader({
+  return new _APILoader2.default({
     key: key,
     useAMapUI: false,
     version: '1.4.7',
     protocol: 'https'
   }).load();
 };
-export var loadMap = function loadMap(key) {
+//import loadjscssfile from './loadScript';
+var loadMap = exports.loadMap = function loadMap(key) {
   return new Promise(function (resolve, reject) {
     if (window.AMap) {
       resolve(window.AMap);
@@ -64,7 +82,7 @@ export var loadMap = function loadMap(key) {
  *  map.addControl(toolbar);
  * @param {string} name 插件名或插件数组,如:AMap.ToolBar,['AMap.ToolBar','AMap.Driving']
  */
-export var loadPlugin = function loadPlugin(name) {
+var loadPlugin = exports.loadPlugin = function loadPlugin(name) {
   return new Promise(function (resolve, reject) {
     if (window.AMap) {
       window.AMap.plugin(name, function () {
@@ -80,7 +98,7 @@ export var loadPlugin = function loadPlugin(name) {
 ////////////////////////////////////////////////////////////
 // Map
 ////////////////////////////////////////////////////////////
-export var createMap = function createMap(AMap, dom, options, events) {
+var createMap = exports.createMap = function createMap(AMap, dom, options, events) {
   var __func__ = 'createMap';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -91,7 +109,7 @@ export var createMap = function createMap(AMap, dom, options, events) {
     return null;
   }
   var map = new AMap.Map(dom, babelHelpers.extends({}, options || {}));
-  forOwn(events, function (value, key) {
+  (0, _forOwn2.default)(events, function (value, key) {
     console.log(__func__, 'event on ' + key);
     map.on(key, value);
   });
@@ -99,7 +117,7 @@ export var createMap = function createMap(AMap, dom, options, events) {
   return map;
 };
 
-export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, oldOptions, oldEvents, operators) {
+var commonUpdate = exports.commonUpdate = function commonUpdate(entity, newOptions, newEvents, oldOptions, oldEvents, operators) {
   var __func__ = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 'commonUpdate';
 
   // const __func__ = 'commonUpdate';
@@ -111,17 +129,17 @@ export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, o
   // 找到改变的属性集合,包含添加,删除及修改的属性,删除的置为null
   var props = {};
   if (newOptions != oldOptions) {
-    oldOptions && forOwn(oldOptions, function (value, key) {
+    oldOptions && (0, _forOwn2.default)(oldOptions, function (value, key) {
       // 找到改变的旧属性,用新属性取代
       var newValue = newOptions && newOptions[key];
-      if (!isEqual(newValue, value)) {
-        if (!(isNil(newValue) && isNil(value))) props[key] = newValue;
+      if (!(0, _isEqual2.default)(newValue, value)) {
+        if (!((0, _isNil2.default)(newValue) && (0, _isNil2.default)(value))) props[key] = newValue;
       }
     });
-    newOptions && forOwn(newOptions, function (value, key) {
+    newOptions && (0, _forOwn2.default)(newOptions, function (value, key) {
       // 找到新加的属性,添加进去
       var oldValue = oldOptions && oldOptions[key];
-      if (isNil(oldValue) && !isNil(value)) {
+      if ((0, _isNil2.default)(oldValue) && !(0, _isNil2.default)(value)) {
         props[key] = value;
       }
     });
@@ -129,17 +147,17 @@ export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, o
   // 找到改变的事件集合,包含添加,删除及修改的事件处理函数,删除的置为null
   var events = {};
   if (newEvents != oldEvents) {
-    oldEvents && forOwn(oldEvents, function (value, key) {
+    oldEvents && (0, _forOwn2.default)(oldEvents, function (value, key) {
       // 找到改变的旧属性,用新属性取代
       var newValue = newEvents && newEvents[key];
-      if (!isEqual(newValue, value)) {
-        if (!(isNil(newValue) && isNil(value))) events[key] = newValue;
+      if (!(0, _isEqual2.default)(newValue, value)) {
+        if (!((0, _isNil2.default)(newValue) && (0, _isNil2.default)(value))) events[key] = newValue;
       }
     });
-    newEvents && forOwn(newEvents, function (value, key) {
+    newEvents && (0, _forOwn2.default)(newEvents, function (value, key) {
       // 找到新加的属性,添加进去
       var oldValue = oldEvents && oldEvents[key];
-      if (isNil(oldValue) && !isNil(value)) {
+      if ((0, _isNil2.default)(oldValue) && !(0, _isNil2.default)(value)) {
         events[key] = value;
       }
     });
@@ -169,7 +187,7 @@ export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, o
   //   label: v => entity.setLabel(v)
   // };
 
-  forOwn(props, function (value, key) {
+  (0, _forOwn2.default)(props, function (value, key) {
     if (value) {
       var func = operators[key];
       if (func) {
@@ -183,7 +201,7 @@ export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, o
       console.log(__func__, 'warning! remove prop not support! key=' + key);
     }
   });
-  forOwn(events, function (value, key) {
+  (0, _forOwn2.default)(events, function (value, key) {
     var oldFunc = oldEvents && oldEvents[key];
     if (oldFunc) {
       entity.off(key, oldFunc);
@@ -201,7 +219,7 @@ export var commonUpdate = function commonUpdate(entity, newOptions, newEvents, o
   return true;
 };
 
-export var updateMap = function updateMap(map, newOptions, newEvents, oldOptions, oldEvents) {
+var updateMap = exports.updateMap = function updateMap(map, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     view: null,
     layers: function layers(v) {
@@ -279,7 +297,7 @@ export var updateMap = function updateMap(map, newOptions, newEvents, oldOptions
  * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
  * @param {*} events
  */
-export var createMarker = function createMarker(AMap, options, events) {
+var createMarker = exports.createMarker = function createMarker(AMap, options, events) {
   var __func__ = 'createMarker';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -299,14 +317,14 @@ export var createMarker = function createMarker(AMap, options, events) {
   // });
   // marker.setMap(map);
   var entity = new AMap.Marker(options);
-  forOwn(events, function (value, key) {
+  (0, _forOwn2.default)(events, function (value, key) {
     entity.on(key, value);
   });
   console.log(__func__, 'ok!');
   return entity;
 };
 
-export var updateMarker = function updateMarker(entity, newOptions, newEvents, oldOptions, oldEvents) {
+var updateMarker = exports.updateMarker = function updateMarker(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     map: function map(v) {
       return entity.setMap(v);
@@ -391,7 +409,7 @@ var createMassMarks = function createMassMarks(AMap, options, events) {
       restOpts = babelHelpers.objectWithoutProperties(options, ['map', 'data']);
 
   var entity = new AMap.MassMarks(data, restOpts);
-  forOwn(events, function (value, key) {
+  (0, _forOwn2.default)(events, function (value, key) {
     entity.on(key, value);
   });
   if (map) {
@@ -401,8 +419,8 @@ var createMassMarks = function createMassMarks(AMap, options, events) {
   return entity;
 };
 
-export { createMassMarks };
-export var updateMassMarks = function updateMassMarks(entity, newOptions, newEvents, oldOptions, oldEvents) {
+exports.createMassMarks = createMassMarks;
+var updateMassMarks = exports.updateMassMarks = function updateMassMarks(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     zIndex: function zIndex(v) {
       return entity.setzIndex(v);
@@ -437,7 +455,7 @@ export var updateMassMarks = function updateMassMarks(entity, newOptions, newEve
  * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
  * @param {*} events
  */
-export var createPolygon = function createPolygon(AMap, options, events) {
+var createPolygon = exports.createPolygon = function createPolygon(AMap, options, events) {
   var __func__ = 'createPolygon';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -452,14 +470,14 @@ export var createPolygon = function createPolygon(AMap, options, events) {
     return null;
   }
   var entity = new AMap.Polygon(options);
-  forOwn(events, function (value, key) {
+  (0, _forOwn2.default)(events, function (value, key) {
     entity.on(key, value);
   });
   console.log(__func__, 'ok!');
   return entity;
 };
 
-export var updatePolygon = function updatePolygon(entity, newOptions, newEvents, oldOptions, oldEvents) {
+var updatePolygon = exports.updatePolygon = function updatePolygon(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     map: function map(v) {
       return entity.setMap(v);
@@ -501,7 +519,7 @@ export var updatePolygon = function updatePolygon(entity, newOptions, newEvents,
  * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
  * @param {*} events
  */
-export var createPolyline = function createPolyline(AMap, options, events) {
+var createPolyline = exports.createPolyline = function createPolyline(AMap, options, events) {
   var __func__ = 'createPolyline';
   if (!AMap) {
     console.log(__func__, 'fail! no AMap!');
@@ -516,14 +534,14 @@ export var createPolyline = function createPolyline(AMap, options, events) {
     return null;
   }
   var entity = new AMap.Polyline(options);
-  forOwn(events, function (value, key) {
+  (0, _forOwn2.default)(events, function (value, key) {
     entity.on(key, value);
   });
   console.log(__func__, 'ok!');
   return entity;
 };
 
-export var updatePolyline = function updatePolyline(entity, newOptions, newEvents, oldOptions, oldEvents) {
+var updatePolyline = exports.updatePolyline = function updatePolyline(entity, newOptions, newEvents, oldOptions, oldEvents) {
   var operators = {
     map: function map(v) {
       return entity.setMap(v);

+ 13 - 5
lib/loadScript.js

@@ -1,12 +1,20 @@
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+
+var _indexOf = require('lodash/indexOf');
+
+var _indexOf2 = babelHelpers.interopRequireDefault(_indexOf);
+
+var gFileList = []; //list of files already added
 /**
  * see: http://www.javascriptkit.com/javatutors/loadjavascriptcss.shtml
  */
-import indexOf from 'lodash/indexOf';
-
-var gFileList = []; //list of files already added
 var loadjscssfile = function loadjscssfile(filename, filetype) {
   return new Promise(function (resolve, reject) {
-    if (indexOf(gFileList, filename) >= 0) {
+    if ((0, _indexOf2.default)(gFileList, filename) >= 0) {
       console.log('loadScript: already load! ' + filename);
       resolve(true);
       return;
@@ -47,4 +55,4 @@ var loadjscssfile = function loadjscssfile(filename, filetype) {
   });
 };
 
-export default loadjscssfile;
+exports.default = loadjscssfile;

+ 27 - 9
lib/webservice.js

@@ -1,12 +1,30 @@
-import forOwn from 'lodash/forOwn';
-import isEqual from 'lodash/isEqual';
-import isNil from 'lodash/isNil';
-import isUndefined from 'lodash/isUndefined';
+'use strict';
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.getRequest = exports.infocode = exports.services = undefined;
+
+var _forOwn = require('lodash/forOwn');
+
+var _forOwn2 = babelHelpers.interopRequireDefault(_forOwn);
+
+var _isEqual = require('lodash/isEqual');
+
+var _isEqual2 = babelHelpers.interopRequireDefault(_isEqual);
+
+var _isNil = require('lodash/isNil');
+
+var _isNil2 = babelHelpers.interopRequireDefault(_isNil);
+
+var _isUndefined = require('lodash/isUndefined');
+
+var _isUndefined2 = babelHelpers.interopRequireDefault(_isUndefined);
 
 // M: Mandatory,必选
 // api调用限流说明: https://lbs.amap.com/api/webservice/guide/tools/flowlevel
 
-export var services = {
+var services = exports.services = {
   // 地理/逆地理编码: https://lbs.amap.com/api/webservice/guide/api/georegeo
   geocode_geo: {
     name: '地理编码',
@@ -332,7 +350,7 @@ export var services = {
 
 };
 
-export var infocode = {
+var infocode = exports.infocode = {
   "10000": {
     info: 'OK',
     desc: '请求正常',
@@ -350,7 +368,7 @@ export var infocode = {
   }
 };
 
-export var getRequest = function getRequest(service, parameters, body) {
+var getRequest = exports.getRequest = function getRequest(service, parameters, body) {
   if (!service) return null;
 
   var option = {};
@@ -364,8 +382,8 @@ export var getRequest = function getRequest(service, parameters, body) {
 
   // 组建url中参数
   var paramArr = [];
-  forOwn(destParameters, function (value, key) {
-    if (!isNil(value)) {
+  (0, _forOwn2.default)(destParameters, function (value, key) {
+    if (!(0, _isNil2.default)(value)) {
       paramArr.push(key + '=' + value);
     }
   });

+ 4 - 7
package.json

@@ -1,6 +1,6 @@
 {
   "name": "react-amap-next",
-  "version": "1.1.1",
+  "version": "1.1.2",
   "description": "这是高德地图的react版本,相比react-amap更加简单,更加贴合react用户",
   "keywords": [
     "react",
@@ -31,6 +31,7 @@
     "babel-plugin-transform-class-properties": "^6.24.1",
     "babel-plugin-transform-object-rest-spread": "^6.26.0",
     "babel-preset-env": "^1.6.1",
+    "babel-preset-es2015": "^6.24.1",
     "babel-preset-react": "^6.24.1",
     "cross-env": "^5.1.4",
     "prop-types": "^15.6.0"
@@ -39,12 +40,8 @@
     "env": {
       "umd": {
         "presets": [
-          [
-            "env",
-            {
-              "modules": false
-            }
-          ],
+          "es2015",
+          "env",
           "react"
         ],
         "plugins": [

File diff suppressed because it is too large
+ 78 - 477
yarn.lock


Some files were not shown because too many files changed in this diff