old_contents: import { DEFAULT_LOCATION } from '../utils/constants';
  
  export const currentLocation = (location) => {
    return {
      type: 'CURRENT_LOCATION',
      location,
    }
  }
  
  export const nearbyLocations = (data) => {
    return {
      type: 'NEARBY_LOCATIONS',
      data,
    }
  }
  
  export const mapCenter = (position) => {
    return {
      type: 'CENTER',
      position
    }
  }
  
  export const geolocate = () => {
    return (dispatch) => {
  
      if ('geolocation' in navigator) {
        navigator.geolocation.getCurrentPosition((position) => {
          const { coords } = position;
          const coordinates = {
            lat: coords.latitude,
            lng: coords.longitude,
          }
  
          dispatch(currentLocation(coordinates));
        });
      } else {
  
        dispatch(currentLocation(DEFAULT_LOCATION.coordinates));
      }
    }
  }
  
new_contents: import { DEFAULT_LOCATION } from '../utils/constants';
  
  export const currentLocation = (location) => {
    return {
      type: 'CURRENT_LOCATION',
      location,
    }
  }
  
  export const nearbyLocations = (data) => {
    return {
      type: 'NEARBY_LOCATIONS',
      data,
    }
  }
  
  export const mapCenter = (position) => {
    return {
      type: 'CENTER',
      position
    }
  }
  
  export const geolocate = () => {
    return (dispatch) => {
  
      if ('geolocation' in navigator) {
        navigator.geolocation.getCurrentPosition((position) => {
          const { coords } = position;
          const coordinates = {
            lat: coords.latitude,
            lng: coords.longitude,
          }
  
          dispatch(currentLocation(coordinates));
          dispatch(mapCenter(coordinates));
        });
      } else {
  
        dispatch(currentLocation(DEFAULT_LOCATION.coordinates));
      }
    }
  }
  
subject: fix centering on map