2019-03-29 17:12:43 +00:00
|
|
|
import L from 'leaflet';
|
2019-12-04 03:59:44 +00:00
|
|
|
import ReactDOM from 'ReactDOM';
|
|
|
|
import React from 'React';
|
2019-03-30 23:07:24 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2019-03-29 17:12:43 +00:00
|
|
|
import './Contours.scss';
|
|
|
|
import ContoursPanel from './ContoursPanel';
|
|
|
|
|
|
|
|
class ContoursButton extends React.Component {
|
2019-03-30 23:07:24 +00:00
|
|
|
static propTypes = {
|
2019-04-01 20:49:56 +00:00
|
|
|
tasks: PropTypes.object.isRequired,
|
|
|
|
map: PropTypes.object.isRequired
|
2019-03-30 23:07:24 +00:00
|
|
|
}
|
|
|
|
|
2019-03-29 17:12:43 +00:00
|
|
|
constructor(props){
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
showPanel: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
handleOpen = () => {
|
|
|
|
this.setState({showPanel: true});
|
|
|
|
}
|
|
|
|
|
|
|
|
handleClose = () => {
|
|
|
|
this.setState({showPanel: false});
|
|
|
|
}
|
|
|
|
|
|
|
|
render(){
|
|
|
|
const { showPanel } = this.state;
|
|
|
|
|
|
|
|
return (<div className={showPanel ? "open" : ""}>
|
|
|
|
<a href="javascript:void(0);"
|
|
|
|
onClick={this.handleOpen}
|
|
|
|
className="leaflet-control-contours-button leaflet-bar-part theme-secondary"></a>
|
2019-04-01 20:49:56 +00:00
|
|
|
<ContoursPanel map={this.props.map} isShowed={showPanel} tasks={this.props.tasks} onClose={this.handleClose} />
|
2019-03-29 17:12:43 +00:00
|
|
|
</div>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default L.Control.extend({
|
|
|
|
options: {
|
|
|
|
position: 'topright'
|
|
|
|
},
|
|
|
|
|
|
|
|
onAdd: function (map) {
|
|
|
|
var container = L.DomUtil.create('div', 'leaflet-control-contours leaflet-bar leaflet-control');
|
|
|
|
L.DomEvent.disableClickPropagation(container);
|
2019-04-01 20:49:56 +00:00
|
|
|
ReactDOM.render(<ContoursButton map={this.options.map} tasks={this.options.tasks} />, container);
|
2019-03-29 17:12:43 +00:00
|
|
|
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|