/* 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; const defOpacity = 0.7; 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, osmcolor: PropTypes.bool, terrain: PropTypes.bool, satellite: PropTypes.bool }; DefMapLayers.defaultProps = { gray: false, osmcolor: false, terrain: false, satellite: false }; export default translate([], { wait: true })(DefMapLayers);