|
@@ -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);
|