EugeneBosyakov

Untitled

Feb 10th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. export class Livemap extends Component {
  3.     componentDidMount() {
  4.         var map = this.map = L.map(ReactDOM.findDOMNode(this), {
  5.             minZoom: 2,
  6.             maxZoom: 20,
  7.             layers: [
  8.                 L.tileLayer(
  9.                     'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
  10.                     {attribution: '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'})
  11.             ],
  12.             attributionControl: false,
  13.         });
  14.  
  15.         map.on('click', this.onMapClick);
  16.         map.fitWorld();
  17.     }
  18.  
  19.     componentWillUnmount() {
  20.         this.map.off('click', this.onMapClick);
  21.         this.map = null;
  22.     }
  23.  
  24.     onMapClick() {
  25.         // Do some wonderful map things...
  26.     }
  27.  
  28.     render() {
  29.         return (
  30.             <div className='mainmap'></div>
  31.         );
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment