diff --git a/imports/ui/components/Maps/DefMapLayers.js b/imports/ui/components/Maps/DefMapLayers.js new file mode 100644 index 0000000..d9df56d --- /dev/null +++ b/imports/ui/components/Maps/DefMapLayers.js @@ -0,0 +1,76 @@ +/* eslint-disable react/jsx-indent-props */ +/* eslint-disable import/no-absolute-path */ +/* eslint-disable import/no-absolute-path */ + +import React, { Component } from 'react'; +import PropTypes from 'prop-types'; +import { translate } from 'react-i18next'; +import { GoogleLayer } from 'react-leaflet-google/lib/'; +import Gkeys from '/imports/startup/client/Gkeys'; +import { TileLayer, LayersControl } from 'react-leaflet'; + +const { BaseLayer } = LayersControl; + +class DefMapLayers extends Component { + constructor(props) { + super(props); + this.state = { + gkey: null + }; + } + + componentDidMount() { + const self = this; + Gkeys.load((err, key) => { + self.setState({ gkey: key }); + }); + } + + render() { + const { t } = this.props; + const osmgraylayer = ( + + + ); + const osmlayer = ( + + + ); + return ( + + {osmlayer} + {osmgraylayer} + {/* React.Fragment does not work here */} + { this.state.gkey && + + + } + { this.state.gkey && + + + } + { this.state.gkey && + + + } + + ); + } +} + +DefMapLayers.propTypes = { + t: PropTypes.func.isRequired, + gray: PropTypes.bool +}; + +DefMapLayers.defaultProps = { + gray: true +}; + +export default translate([], { wait: true })(DefMapLayers);