|
@@ -1,7 +1,7 @@
|
|
import React, { Component, PureComponent } from 'react';
|
|
import React, { Component, PureComponent } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
import { createMarker, updateMarker } from './api';
|
|
import { createMarker, updateMarker } from './api';
|
|
-const __component__ = 'Marker';
|
|
|
|
|
|
+const __com__ = 'Marker';
|
|
//const debug = console.log;
|
|
//const debug = console.log;
|
|
const debug = () => {};
|
|
const debug = () => {};
|
|
|
|
|
|
@@ -24,15 +24,15 @@ export class Marker extends Component {
|
|
super();
|
|
super();
|
|
this.refElement = null;
|
|
this.refElement = null;
|
|
this._entity = null;
|
|
this._entity = null;
|
|
- debug(__component__, 'constructor', this._entity);
|
|
|
|
|
|
+ debug(__com__, 'constructor', this._entity);
|
|
}
|
|
}
|
|
|
|
|
|
componentWillMount() {
|
|
componentWillMount() {
|
|
- debug(__component__, 'componentWillMount', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'componentWillMount', this.props.children, this._entity);
|
|
}
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
- debug(__component__, 'componentDidMount', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'componentDidMount', this.props.children, this._entity);
|
|
let { AMap, __map__, options, events, children } = this.props;
|
|
let { AMap, __map__, options, events, children } = this.props;
|
|
//let opts = { ...(options || {}), map: __map__, content: children };
|
|
//let opts = { ...(options || {}), map: __map__, content: children };
|
|
let opts = { ...(options || {}), map: __map__ };
|
|
let opts = { ...(options || {}), map: __map__ };
|
|
@@ -43,15 +43,15 @@ export class Marker extends Component {
|
|
}
|
|
}
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
componentWillReceiveProps(nextProps) {
|
|
- debug(__component__, 'componentWillReceiveProps', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'componentWillReceiveProps', this.props.children, this._entity);
|
|
}
|
|
}
|
|
|
|
|
|
componentWillUpdate() {
|
|
componentWillUpdate() {
|
|
- debug(__component__, 'componentWillUpdate', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'componentWillUpdate', this.props.children, this._entity);
|
|
}
|
|
}
|
|
|
|
|
|
componentDidUpdate(prevProps) {
|
|
componentDidUpdate(prevProps) {
|
|
- debug(__component__, 'componentDidUpdate', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'componentDidUpdate', this.props.children, this._entity);
|
|
let { AMap, __map__, options, events, children } = this.props;
|
|
let { AMap, __map__, options, events, children } = this.props;
|
|
//let opts = { ...(options || {}), map: __map__, content: children };
|
|
//let opts = { ...(options || {}), map: __map__, content: children };
|
|
let opts = { ...(options || {}), map: __map__ };
|
|
let opts = { ...(options || {}), map: __map__ };
|
|
@@ -73,18 +73,30 @@ export class Marker extends Component {
|
|
}
|
|
}
|
|
|
|
|
|
componentWillUnmount() {
|
|
componentWillUnmount() {
|
|
- debug(__component__, 'componentWillUnmount', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'componentWillUnmount', this.props.children, this._entity);
|
|
if (this._entity) {
|
|
if (this._entity) {
|
|
// this._entity.clearMap();
|
|
// this._entity.clearMap();
|
|
this._entity.setMap(null);
|
|
this._entity.setMap(null);
|
|
delete this._entity;
|
|
delete this._entity;
|
|
// delete this._entity;
|
|
// delete this._entity;
|
|
this._entity = null;
|
|
this._entity = null;
|
|
|
|
+ if (this.props.refer) this.props.refer(this._entity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // shouldComponentUpdate(nextProps, nextState) {
|
|
|
|
+ // debug(__com__, 'shouldComponentUpdate', this._entity);
|
|
|
|
+ // let { AMap: oldAMap, refer: oldRefer, options: oldOptions, events: oldEvents } = this.props;
|
|
|
|
+ // let { AMap: newAMap, refer: newRefer, options: newOptions, events: newEvents } = nextProps;
|
|
|
|
+ // if (oldAMap === newAMap && oldRefer === newRefer && oldOptions === newOptions && oldEvents === newEvents) {
|
|
|
|
+ // debug(__com__, 'shouldComponentUpdate', false);
|
|
|
|
+ // return false;
|
|
|
|
+ // }
|
|
|
|
+ // debug(__com__, 'shouldComponentUpdate', true);
|
|
|
|
+ // return true;
|
|
|
|
+ // }
|
|
render() {
|
|
render() {
|
|
- debug(__component__, 'render', this.props.children, this._entity);
|
|
|
|
|
|
+ debug(__com__, 'render', this.props.children, this._entity);
|
|
let {
|
|
let {
|
|
AMap,
|
|
AMap,
|
|
options,
|
|
options,
|