|
@@ -9,8 +9,8 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
//import loadjscssfile from './loadScript';
|
|
|
import APILoader from './APILoader';
|
|
|
|
|
|
-//const xdebug = console.log;
|
|
|
-var xdebug = function xdebug() {};
|
|
|
+var xdebug = console.log;
|
|
|
+// const xdebug = () => {};
|
|
|
|
|
|
export var loadApi = function loadApi() {
|
|
|
var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '0325e3d6d69cd56de4980b4f28906fd8';
|
|
@@ -397,10 +397,9 @@ var createTraffic = function createTraffic(options, events) {
|
|
|
}
|
|
|
|
|
|
var map = options.map,
|
|
|
- data = options.data,
|
|
|
- restOpts = _objectWithoutProperties(options, ['map', 'data']);
|
|
|
+ restOpts = _objectWithoutProperties(options, ['map']);
|
|
|
|
|
|
- var entity = new window.AMap.TileLayer.Traffic(data, restOpts);
|
|
|
+ var entity = new window.AMap.TileLayer.Traffic(restOpts);
|
|
|
forOwn(events, function (value, key) {
|
|
|
entity.on(key, value);
|
|
|
});
|
|
@@ -424,7 +423,10 @@ export var updateTraffic = function updateTraffic(entity, newOptions, newEvents,
|
|
|
zooms: null,
|
|
|
detectRetina: null,
|
|
|
autoRefresh: null,
|
|
|
- interval: null
|
|
|
+ interval: null,
|
|
|
+ tileUrl: function tileUrl(v) {
|
|
|
+ return entity.setTileUrl(v);
|
|
|
+ } // not in options.
|
|
|
};
|
|
|
|
|
|
return commonUpdate(entity, newOptions, newEvents, oldOptions, oldEvents, operators, 'updateTraffic');
|
|
@@ -489,6 +491,63 @@ export var updateMassMarks = function updateMassMarks(entity, newOptions, newEve
|
|
|
return commonUpdate(entity, newOptions, newEvents, oldOptions, oldEvents, operators, 'updateMassMarks');
|
|
|
};
|
|
|
|
|
|
+// ////////////////////////////////////////////////////////////
|
|
|
+// // Traffic, warning! is a layer!
|
|
|
+// ////////////////////////////////////////////////////////////
|
|
|
+// /**
|
|
|
+// *
|
|
|
+// * @param {*} window.AMap
|
|
|
+// * @param {*} map
|
|
|
+// * @param {*} options 如果有dom用来显示,则其中的content字段即被填充为dom,不再用独立参数表示dom
|
|
|
+// * @param {*} events
|
|
|
+// */
|
|
|
+// export const createTraffic = (options, events) => {
|
|
|
+// const __func__ = 'createTraffic';
|
|
|
+// if (!window.AMap || !options || !options.map) {
|
|
|
+// xdebug(__func__, 'fail! parameters!', 'window.AMap:'+!!window.AMap, 'options:'+!!options, 'options.map:'+!!(options&&options.map));
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+// let {map, data, style, ...restOpts} = options;
|
|
|
+// // let entity = new window.AMap.TileLayer.Traffic(data, restOpts);
|
|
|
+// let entity = new window.AMap.Traffic(data||[], {...restOpts, style: style||[]});
|
|
|
+// forOwn(events, (value, key) => {
|
|
|
+// entity.on(key, value);
|
|
|
+// });
|
|
|
+// entity.setMap(map);
|
|
|
+// xdebug(__func__, 'ok!', map, 'layers:', map.getLayers());
|
|
|
+// return entity;
|
|
|
+// };
|
|
|
+
|
|
|
+// export const updateTraffic = (
|
|
|
+// entity,
|
|
|
+// newOptions,
|
|
|
+// newEvents,
|
|
|
+// oldOptions,
|
|
|
+// oldEvents
|
|
|
+// ) => {
|
|
|
+// let operators = {
|
|
|
+// map: v => entity.setMap(v),
|
|
|
+// zIndex: v => entity.setzIndex(v),
|
|
|
+// opacity: v => entity.setOpacity(v),
|
|
|
+// zooms: null,
|
|
|
+// detectRetina: null,
|
|
|
+// autoRefresh: null,
|
|
|
+// interval: null,
|
|
|
+// tileUrl: v => entity.setTileUrl(v), // not in options.
|
|
|
+// };
|
|
|
+// xdebug('updateTraffic', 'mapOld:', (oldOptions && oldOptions.map && oldOptions.map.getLayers()), 'mapNew:', (newOptions && newOptions.map && newOptions.map.getLayers()));
|
|
|
+
|
|
|
+// return commonUpdate (
|
|
|
+// entity,
|
|
|
+// newOptions,
|
|
|
+// newEvents,
|
|
|
+// oldOptions,
|
|
|
+// oldEvents,
|
|
|
+// operators,
|
|
|
+// 'updateTraffic'
|
|
|
+// )
|
|
|
+// };
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////
|
|
|
// Polygon
|
|
|
////////////////////////////////////////////////////////////
|