MapGLs.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import React, {Profiler} from "react";
  2. import MapGL from "./../maps/MapGL";
  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. didMountSwitchLatLng,
  14. componentDidUpdate,
  15. componentWillUnmount
  16. } from "./../helpers/testLifecycle"
  17. export default class MapGLs 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.componentDidUpdate = componentDidUpdate.bind(this)
  28. this.componentWillUnmount = componentWillUnmount.bind(this)
  29. }
  30. componentDidMount() {
  31. didMountSwitchLatLng(this, true)
  32. }
  33. render(){
  34. return (
  35. <div className="mapTestContainer">
  36. <div className="mapTime">
  37. <CustomInput type="switch" onChange={this.changeSwitch} id="moveSwitch" name="moveSwitch" label="Move markers" />
  38. <div ref={this.markerInfoDiv}>
  39. <span>{this.state.currStep} steps</span>
  40. </div>
  41. <span>Number of Markers: {this.state.noOfMarkers}</span><br/>
  42. <Input type="text" onChange={(e) => this.setNoOfMarkers(e, true)} value={this.state.noOfMarkers}/>
  43. <div ref={this.measurementsDiv}>
  44. </div>
  45. </div>
  46. <div className="mapTest">
  47. <Profiler id="mapgl" onRender={measureTime(this, this.state.noOfMarkers, this.state.markerType)}>
  48. <MapGL markers={this.state.markers}/>
  49. </Profiler>
  50. </div>
  51. </div>
  52. );
  53. }
  54. }