import hash from 'object-hash' import React from 'react' import { GeoJSON, Map, TileLayer } from 'react-leaflet' import { connect } from 'react-redux' import { getActivityGpx } from '../../../actions/activities' import { thunderforestApiKey } from '../../../utils' import { getGeoJson } from '../../../utils/activities' class ActivityMap extends React.Component { constructor(props, context) { super(props, context) this.state = { zoom: 13, } } componentDidMount() { this.props.loadActivityGpx(this.props.activity.id) } componentDidUpdate(prevProps) { if (prevProps.activity.id !== this.props.activity.id) { this.props.loadActivityGpx(this.props.activity.id) } } componentWillUnmount() { this.props.loadActivityGpx(null) } render() { const { activity, gpxContent } = this.props const { jsonData } = getGeoJson(gpxContent) const bounds = [ [activity.bounds[0], activity.bounds[1]], [activity.bounds[2], activity.bounds[3]] ] return (