Guest User

Untitled

a guest
Mar 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. const MapWithAMarkerClusterer = compose(
  2. withProps({
  3. googleMapURL: "MY KEY",
  4. loadingElement: <div style={{ height: `100%` }} />,
  5. containerElement: <div style={{ height: `400px` }} />,
  6. mapElement: <div style={{ height: `100%` }} />,
  7. }),
  8. withHandlers({
  9. onMarkerClustererClick: () => (markerClusterer) => {
  10. const clickedMarkers = markerClusterer.getMarkers()
  11. }
  12. }),
  13. withStateHandlers(() => ({
  14. isOpen: false,
  15. markerId: ''
  16. }), {
  17. onToggleOpen: ({ isOpen }) => (markerId) => ({
  18. isOpen: !isOpen,
  19. markerId: markerId
  20. })
  21. }),
  22. withScriptjs,
  23. withGoogleMap
  24. )(props =>
  25. <GoogleMap
  26. defaultZoom={4}
  27. defaultCenter={{ lat: -23.696248, lng: 133.880731 }}
  28. >
  29. <MarkerClusterer
  30. onClick={props.onMarkerClustererClick}
  31. averageCenter
  32. enableRetinaIcons
  33. gridSize={60}
  34. >
  35. {props.companies.map(company => (
  36. <span key={company.company_name}>
  37. <Marker
  38. position={company.google_maps.geometry_location}
  39. onClick={() => props.onToggleOpen(company.company_name)}
  40. >
  41. {props.isOpen[props.markerId] && <InfoWindow onCloseClick={props.onToggleOpen}>
  42. <p>Test</p>
  43. </InfoWindow>}
  44. </Marker>
  45. </span>
  46. ))}
  47. </MarkerClusterer>
  48. </GoogleMap>
  49. );
Add Comment
Please, Sign In to add comment