Skip to content

Commit

Permalink
fix: #32 import eslint to solve low-level errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JserWang committed Aug 14, 2018
1 parent d631c4e commit 4fc1041
Show file tree
Hide file tree
Showing 45 changed files with 1,051 additions and 312 deletions.
17 changes: 17 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "airbnb",
"parser": "babel-eslint",
"env": {
"browser": true
},
"rules": {
"import/no-extraneous-dependencies": "off",
"no-param-reassign": "warn",
"react/prop-types": "off",
"no-underscore-dangle": "warn",
"global-require": "warn",
"react/jsx-filename-extension": "off",
"react/require-default-props": "off",
"react/forbid-prop-types": "off"
}
}
4 changes: 3 additions & 1 deletion lib/components/Control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ var Control = function (_BaseControl) {
key: 'initialize',
value: function initialize() {
// // 创建一个DOM元素
var container = this.container = document.createElement('div');
var container = document.createElement('div');
this.container = container;

if (this.render) {
(0, _reactDom.render)(this.render(), container);
}
Expand Down
13 changes: 8 additions & 5 deletions lib/components/Lib/CurveLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ Object.defineProperty(exports, "__esModule", {

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class;
var _class; /* eslint-disable */

/* eslint-enable */


var _bmaplib = require('bmaplib.curveline');

var _bmaplib2 = _interopRequireDefault(_bmaplib);

var _BaseOverlay2 = require('../Overlay/BaseOverlay');

Expand All @@ -18,10 +25,6 @@ var _ReactComponent = require('../ReactComponent');

var _ReactComponent2 = _interopRequireDefault(_ReactComponent);

var _bmaplib = require('bmaplib.curveline');

var _bmaplib2 = _interopRequireDefault(_bmaplib);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Expand Down
12 changes: 6 additions & 6 deletions lib/components/Lib/DrawingManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ var DrawingManager = (0, _ReactComponent2.default)(_class = function (_BaseOverl
key: 'init',
value: function init() {
var defaultStyle = {
strokeColor: "red", //边线颜色。
fillColor: "red", //填充颜色。当参数为空时,圆形将没有填充效果。
strokeWeight: 3, //边线的宽度,以像素为单位。
strokeOpacity: 0.8, //边线透明度,取值范围0 - 1。
fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
strokeStyle: 'solid' //边线的样式,solid或dashed。
strokeColor: 'red', // 边线颜色。
fillColor: 'red', // 填充颜色。当参数为空时,圆形将没有填充效果。
strokeWeight: 3, // 边线的宽度,以像素为单位。
strokeOpacity: 0.8, // 边线透明度,取值范围0 - 1。
fillOpacity: 0.6, // 填充的透明度,取值范围0 - 1。
strokeStyle: 'solid' // 边线的样式,solid或dashed。
};

var _props = this.props,
Expand Down
13 changes: 8 additions & 5 deletions lib/components/Lib/Heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ Object.defineProperty(exports, "__esModule", {

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class;
var _class; /* eslint-disable */

/* eslint-enable */


var _bmaplib = require('bmaplib.heatmap');

var _bmaplib2 = _interopRequireDefault(_bmaplib);

var _BaseOverlay2 = require('../Overlay/BaseOverlay');

Expand All @@ -18,10 +25,6 @@ var _ReactComponent = require('../ReactComponent');

var _ReactComponent2 = _interopRequireDefault(_ReactComponent);

var _bmaplib = require('bmaplib.heatmap');

var _bmaplib2 = _interopRequireDefault(_bmaplib);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
Expand Down
18 changes: 11 additions & 7 deletions lib/components/Lib/MarkerClusterer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ Object.defineProperty(exports, "__esModule", {

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _class;
var _class; /* eslint-disable */

/* eslint-enable */


var _bmaplib = require('bmaplib.markerclusterer');

var _bmaplib2 = _interopRequireDefault(_bmaplib);

var _BaseOverlay2 = require('../Overlay/BaseOverlay');

Expand All @@ -18,10 +25,6 @@ var _ReactComponent = require('../ReactComponent');

var _ReactComponent2 = _interopRequireDefault(_ReactComponent);

var _bmaplib = require('bmaplib.markerclusterer');

var _bmaplib2 = _interopRequireDefault(_bmaplib);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
Expand Down Expand Up @@ -56,8 +59,9 @@ var MarkerClusterer = (0, _ReactComponent2.default)(_class = function (_BaseOver

var childrenMakers = children && !Array.isArray(children) ? [children] : children;
var markers = [];
var Marker = global.BMap.Marker;
childrenMakers.map(function (m) {
var Marker = global.BMap.Marker.Marker;

childrenMakers.forEach(function (m) {
var _m$props = m.props,
point = _m$props.point,
markerOpts = _objectWithoutProperties(_m$props, ['point']);
Expand Down
50 changes: 29 additions & 21 deletions lib/components/Map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ var Map = (_temp = _class = function (_React$Component) {

_initialiseProps.call(_this);

_this.defaultCenter = { lng: 116.404, lat: 39.915
// React 16
};if (_react2.default.createRef) {
_this.defaultCenter = { lng: 116.404, lat: 39.915 };
// React 16
if (_react2.default.createRef) {
_this.mapContainerRef = _react2.default.createRef();
} else {
_this.mapContainerRef = function (ref) {
Expand Down Expand Up @@ -79,18 +79,22 @@ var Map = (_temp = _class = function (_React$Component) {
this.processMapOptions(props);
this.processContextMenu(props.contextMenu);
(0, _util.unBindEvents)(map);
props.events && (0, _util.bindEvents)(map, 'MAP', props.events);
if (props.events) (0, _util.bindEvents)(map, 'MAP', props.events);
}
}
}, {
key: 'processProps',
value: function processProps(nextProps) {
var _props = this.props,
center = _props.center,
zoom = _props.zoom;

var props = Object.assign({}, nextProps);
if (JSON.stringify(props.center) === JSON.stringify(this.props.center)) {
if (JSON.stringify(props.center) === JSON.stringify(center)) {
delete props.center;
}

if (props.zoom === this.props.zoom) {
if (props.zoom === zoom) {
delete props.zoom;
}
return props;
Expand Down Expand Up @@ -158,29 +162,32 @@ var Map = (_temp = _class = function (_React$Component) {
var _this2 = this;

this.init = function (BMap) {
var _props = _this2.props,
highResolution = _props.highResolution,
autoResize = _props.autoResize,
mapClick = _props.mapClick,
mapMounted = _props.mapMounted,
contextMenu = _props.contextMenu,
resetProps = _objectWithoutProperties(_props, ['highResolution', 'autoResize', 'mapClick', 'mapMounted', 'contextMenu']);
var _props2 = _this2.props,
highResolution = _props2.highResolution,
autoResize = _props2.autoResize,
mapClick = _props2.mapClick,
mapMounted = _props2.mapMounted,
contextMenu = _props2.contextMenu,
events = _props2.events,
resetProps = _objectWithoutProperties(_props2, ['highResolution', 'autoResize', 'mapClick', 'mapMounted', 'contextMenu', 'events']);

_this2.mapContainer = _this2.mapContainer || _this2.mapContainerRef.current;
var map = _this2.map = new BMap.Map(_this2.mapContainer, {
var map = new BMap.Map(_this2.mapContainer, {
enableHighResolution: highResolution,
enableAutoResize: autoResize,
enableMapClick: mapClick
});

_this2.map = map;
// 当初始化center为string时,保证地图正常渲染,用默认center处理centerAndZoom
if (typeof resetProps.center === "string") {
if (typeof resetProps.center === 'string') {
map.centerAndZoom(_this2.defaultCenter, resetProps.zoom);
}
_this2.processContextMenu(contextMenu);

global.bMapInstance = map;
_this2.processMapOptions(resetProps);
(0, _util.bindEvents)(map, 'MAP', _this2.props.events);
(0, _util.bindEvents)(map, 'MAP', events);

// 地图配置完成后,强制刷新,渲染子组件
_this2.forceUpdate(function () {
Expand All @@ -207,7 +214,8 @@ var Map = (_temp = _class = function (_React$Component) {
(0, _util.processBooleanOptions)(map, 'MAP_BOOLEAN_OPTIONS', props);

if (props.center) {
var center = props.center;
var center = props.center.center;

if ((0, _util.isPoint)(center)) {
center = (0, _util.getPoint)(center.lng, center.lat);
}
Expand All @@ -228,21 +236,21 @@ var Map = (_temp = _class = function (_React$Component) {

global.BMap = global.BMap || {};
if (Object.keys(global.BMap).length === 0) {
global.BMap._preloader = new Promise(function (resolve, reject) {
global.BMap._preloader = new Promise(function (resolve) {
var $script = document.createElement('script');
global.document.body.appendChild($script);
global._initBaiduMap = function initBaiduMap() {
resolve(global.BMap);
global.document.body.removeChild($script);
global.BMap._preloader = null;
global._initBaiduMap = null;
};

var $script = document.createElement('script');
global.document.body.appendChild($script);
$script.src = 'https://api.map.baidu.com/api?v=3.0&ak=' + ak + '&callback=_initBaiduMap';
});

return global.BMap._preloader;
} else if (!global.BMap._preloader) {
}if (!global.BMap._preloader) {
return Promise.resolve(global.BMap);
}
return global.BMap._preloader;
Expand Down
2 changes: 0 additions & 2 deletions lib/components/Overlay/BaseOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ var _createClass = function () { function defineProperties(target, props) { for

var _reactDom = require('react-dom');

var _util = require('../_base/util');

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var BaseOverlay = function () {
Expand Down
8 changes: 5 additions & 3 deletions lib/components/Overlay/Boundary.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var Boundary = (0, _ReactComponent2.default)(_class = function (_BaseOverlay) {
autoViewport = _props.autoViewport,
polygonOpts = _objectWithoutProperties(_props, ['name', 'onError', 'autoViewport']);

this.getBoundary(name).then(function (points) {
this.getBoundary().then(function (points) {
polygonOpts.points = points;
_this2.instance = (0, _util.createPolygon)(polygonOpts);
_this2.map.addOverlay(_this2.instance);
Expand All @@ -66,14 +66,16 @@ var Boundary = (0, _ReactComponent2.default)(_class = function (_BaseOverlay) {
}
}, {
key: 'getBoundary',
value: function getBoundary(name) {
value: function getBoundary() {
var name = this.props.name;

return new Promise(function (resolve, reject) {
var boundary = new global.BMap.Boundary();

boundary.get(name, function (res) {
var count = res.boundaries.length;
if (count === 0) {
reject('未能获取当前输入行政区域');
reject();
}
var points = res.boundaries[0].split(';').map(function (item) {
var pointArr = item.split(',');
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Overlay/InfoWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var InfoWindow = (0, _ReactComponent2.default)(_class = function (_BaseOverlay)
};

this.instance = new global.BMap.InfoWindow(content, opts);
this.map.openInfoWindow(this.instance, getPoint(point.lng, point.lat));
this.map.openInfoWindow(this.instance, (0, _util.getPoint)(point.lng, point.lat));
(0, _util.bindEvents)(this.instance, 'INFO_WINDOW', events);
}
}]);
Expand Down
4 changes: 2 additions & 2 deletions lib/components/Overlay/PointCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ var PointCollection = (0, _ReactComponent2.default)(_class = function (_BaseOver


var opts = {
shape: shape && top[shape],
shape: shape && global[shape],
color: color,
size: size && top[size]
size: size && global[size]
};

var pList = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/components/Overlay/Polyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var Polyline = (0, _ReactComponent2.default)(_class = function (_BaseOverlay) {
massClear: massClear,
editing: editing
};
processBooleanOptions(this.instance, 'POLYLINE_BOOLEAN_OPTIONS', booleanOpts);
(0, _util.processBooleanOptions)(this.instance, 'POLYLINE_BOOLEAN_OPTIONS', booleanOpts);
(0, _util.bindEvents)(this.instance, 'POLYLINE', events);
}
}]);
Expand Down
7 changes: 4 additions & 3 deletions lib/components/Overlay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var BOverlay = function BOverlay() {};
var BOverlay = function Empty() {};

var Overlay = function (_BaseOverlay) {
_inherits(Overlay, _BaseOverlay);
Expand Down Expand Up @@ -57,7 +57,9 @@ var Overlay = function (_BaseOverlay) {
pane = _props$pane === undefined ? _MapPane2.default.MARKER : _props$pane,
zIndex = _props.zIndex;

var container = this.container = document.createElement('div');
var container = document.createElement('div');
this.container = container;

if (zIndex) {
container.style.zIndex = zIndex;
}
Expand All @@ -73,7 +75,6 @@ var Overlay = function (_BaseOverlay) {
value: function draw() {
var container = this.container,
props = this.props;
;
var point = props.point;

var position = this.map.pointToOverlayPixel((0, _util.getPoint)(point.lng, point.lat));
Expand Down
6 changes: 4 additions & 2 deletions lib/components/ReactComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ function ReactComponent(Wrapped) {
var _this = _possibleConstructorReturn(this, (Proxy.__proto__ || Object.getPrototypeOf(Proxy)).call(this, props));

_this.getInstance = function () {
if (_this.props.getInstance) {
_this.props.getInstance(_this.wrapped.instance);
var getInstance = _this.props.getInstance;

if (getInstance) {
getInstance(_this.wrapped.instance);
}
};

Expand Down
Loading

0 comments on commit 4fc1041

Please sign in to comment.