Googles.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, {Profiler} from "react";
  2. import Google from "./../maps/Google";
  3. import {measureTime} from './../helpers/measureTime';
  4. import {CustomInput, Input} from "reactstrap";
  5. import {mapTestState} from "./../config/variables"
  6. import {
  7. createRandomMarkers,
  8. calcMarkerPosition,
  9. changeSwitch,
  10. setNoOfMarkers
  11. } from "./../helpers/randomMarkers";
  12. import {
  13. componentDidMount,
  14. componentDidUpdate,
  15. componentWillUnmount
  16. } from "./../helpers/testLifecycle"
  17. export default class Googles extends React.Component{
  18. constructor(props) {
  19. super(props)
  20. this.state = mapTestState
  21. this.measurementsDiv = React.createRef()
  22. this.markerInfoDiv = React.createRef()
  23. this.createRandomMarkers = createRandomMarkers.bind(this)
  24. this.calcMarkerPosition = calcMarkerPosition.bind(this)
  25. this.changeSwitch = changeSwitch.bind(this)
  26. this.setNoOfMarkers = setNoOfMarkers.bind(this)
  27. this.componentDidMount = componentDidMount.bind(this)
  28. this.componentDidUpdate = componentDidUpdate.bind(this)
  29. this.componentWillUnmount = componentWillUnmount.bind(this)
  30. }
  31. render(){
  32. return (
  33. <div className="mapTestContainer">
  34. <div className="mapTime">
  35. <CustomInput type="switch" onChange={this.changeSwitch} id="moveSwitch" name="moveSwitch" label="Move markers" />
  36. <div ref={this.markerInfoDiv}>
  37. <span>{this.state.currStep} steps</span>
  38. </div>
  39. <span>Number of Markers: {this.state.noOfMarkers}</span><br/>
  40. <Input type="text" onChange={this.setNoOfMarkers} value={this.state.noOfMarkers}/>
  41. <div ref={this.measurementsDiv}>
  42. </div>
  43. </div>
  44. <div className="mapTest">
  45. <Profiler id="google" onRender={measureTime(this, this.state.noOfMarkers)}>
  46. <Google markers={this.state.markers}/>
  47. </Profiler>
  48. </div>
  49. </div>
  50. );
  51. }
  52. }