Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. import GoogleMapReact from 'google-map-react';
  2. import Geocode from "react-geocode";
  3. ...//other imports
  4.  
  5. const AnyReactComponent = ({ text }) => <div>{text}</div>;
  6. class History extends Component {
  7. static defaultProps = {
  8. center: {
  9. lat: 59.95,
  10. lng: 30.33
  11. },
  12. zoom: 11
  13. };
  14. static async getInitialProps(props) {
  15. let addresscounts = await tracker.methods.zipCounts().call()
  16.  
  17. let addressArray = await Promise.all(
  18. Array(parseInt(addresscounts))
  19. .fill()
  20. .map((element, index) => {
  21. return tracker.methods.zipcodes(props.query.id,index).call();
  22. })
  23. );
  24. //////////////////////////react-geocode////////////////////
  25. Geocode.setApiKey("AIzaSyCdVP9OOKwKsMHJhgmd0nhI3_PZCX5zRXI");
  26. Geocode.fromAddress("Eiffel Tower").then(
  27. response => {
  28. const { lat, lng } = response.results[0].geometry.location;
  29. console.log(lat, lng);
  30. },
  31. error => { console.error(error);});
  32. ///////////////////////////////////
  33. return {
  34. addressArray
  35. };
  36. }
  37.  
  38. render(){
  39.  
  40. return(
  41. <div style={{ height: '100vh', width: '100%' }}>
  42. <GoogleMapReact
  43. bootstrapURLKeys={{ key: "AIzaSyAG3SH8vY-c04ljXBQO9mEPsOWQxLl_jcM"}}
  44. defaultCenter={this.props.center}
  45. defaultZoom={this.props.zoom}
  46. >
  47. <AnyReactComponent
  48. lat={59.955413}
  49. lng={30.337844}
  50. text="My Marker"
  51. />
  52. </GoogleMapReact>
  53. </div>
  54. );
  55. }
  56. }
  57. export default History;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement