/* eslint-disable no-undef */ import React from 'react'; import { compose, withProps, lifecycle } from 'recompose'; import { withScriptjs, withGoogleMap, GoogleMap, DirectionsRenderer, } from 'react-google-maps'; const MapWithADirectionsRenderer = compose( withProps({ googleMapURL: 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places', loadingElement:
, containerElement: , mapElement: , }), withScriptjs, withGoogleMap, lifecycle({ componentDidMount() { const DirectionsService = new google.maps.DirectionsService(); DirectionsService.route({ origin: new google.maps.LatLng(41.8507300, -87.6512600), destination: new google.maps.LatLng(41.8525800, -87.6514100), travelMode: google.maps.TravelMode.DRIVING, }, (result, status) => { if (status === google.maps.DirectionsStatus.OK) { this.setState({ directions: result, }); } else { console.error(`error fetching directions ${result}`); } }); } }) )(props => (