diff --git a/src/components/Map/Map.example.js b/src/components/Map/Map.example.js
index 2b9da873..1a6e7684 100644
--- a/src/components/Map/Map.example.js
+++ b/src/components/Map/Map.example.js
@@ -13,6 +13,7 @@ export const WithMarker = {
),
props: {
center: new LatLng(60.16502999999999, 24.940064399999983),
+ obfuscatedCenter: new LatLng(60.16502999999999, 24.940064399999983),
address: 'Sharetribe',
zoom: 22,
},
@@ -26,6 +27,7 @@ export const WithObfuscatedLocation = {
),
props: {
center: new LatLng(60.16502999999999, 24.940064399999983),
+ obfuscatedCenter: new LatLng(60.16502999999999, 24.940064399999983),
address: 'Sharetribe',
zoom: 14,
coordinatesConfig: {
diff --git a/src/components/Map/Map.js b/src/components/Map/Map.js
index 3e16a6d9..0dfe43f9 100644
--- a/src/components/Map/Map.js
+++ b/src/components/Map/Map.js
@@ -3,7 +3,6 @@ import { string, number, object } from 'prop-types';
import { withGoogleMap, GoogleMap, Marker, Circle } from 'react-google-maps';
import classNames from 'classnames';
import { propTypes } from '../../util/types';
-import { obfuscatedCoordinates } from '../../util/maps';
import config from '../../config';
import CustomMarker from './images/marker-32x32.png';
@@ -70,12 +69,23 @@ export class Map extends Component {
mapRootClassName,
address,
center,
+ obfuscatedCenter,
zoom,
coordinatesConfig,
} = this.props;
const classes = classNames(rootClassName || css.root, className);
const mapClasses = mapRootClassName || css.mapRoot;
- const location = coordinatesConfig.fuzzy ? obfuscatedCoordinates(center) : center;
+
+ if (coordinatesConfig.fuzzy && !obfuscatedCenter) {
+ throw new Error(
+ 'Map: obfuscatedCenter prop is required when config.coordinates.fuzzy === true'
+ );
+ }
+ if (!coordinatesConfig.fuzzy && !center) {
+ throw new Error('Map: center prop is required when config.coordinates.fuzzy === false');
+ }
+
+ const location = coordinatesConfig.fuzzy ? obfuscatedCenter : center;
const centerLocationForGoogleMap = { lat: location.lat, lng: location.lng };
return (
@@ -95,6 +105,7 @@ Map.defaultProps = {
className: null,
rootClassName: null,
mapRootClassName: null,
+ address: '',
zoom: config.coordinates.fuzzy ? config.coordinates.fuzzyDefaultZoomLevel : 11,
coordinatesConfig: config.coordinates,
};
@@ -103,8 +114,9 @@ Map.propTypes = {
className: string,
rootClassName: string,
mapRootClassName: string,
- address: string.isRequired,
- center: propTypes.latlng.isRequired,
+ address: string,
+ center: propTypes.latlng,
+ obfuscatedCenter: propTypes.latlng,
zoom: number,
coordinatesConfig: object,
};
diff --git a/src/components/SearchMap/SearchMap.js b/src/components/SearchMap/SearchMap.js
index cdeb45f1..b4c6447b 100644
--- a/src/components/SearchMap/SearchMap.js
+++ b/src/components/SearchMap/SearchMap.js
@@ -71,14 +71,15 @@ const reducedToArray = mapListings => {
const withCoordinatesObfuscated = listings => {
return listings.map(listing => {
- const { attributes, ...rest } = listing;
- const attrs = {
- ...attributes,
- geolocation: obfuscatedCoordinates(attributes.geolocation),
- };
+ const { id, attributes, ...rest } = listing;
+ const geolocation = obfuscatedCoordinates(attributes.geolocation, id ? id.uuid : null);
return {
+ id,
...rest,
- attributes: attrs,
+ attributes: {
+ ...attributes,
+ geolocation,
+ },
};
});
};
diff --git a/src/config.js b/src/config.js
index 552ec11d..aa1472b5 100644
--- a/src/config.js
+++ b/src/config.js
@@ -241,7 +241,7 @@ const facebookAppId = null;
const coordinates = {
// If true, obfuscate the coordinates of the listings that are shown
// on a map.
- fuzzy: process.env.REACT_APP_FUZZY_COORDINATES || true,
+ fuzzy: process.env.REACT_APP_FUZZY_COORDINATES || false,
fuzzyDefaultZoomLevel: 14,
diff --git a/src/containers/ListingPage/ListingPage.js b/src/containers/ListingPage/ListingPage.js
index 61e719ea..bc043942 100644
--- a/src/containers/ListingPage/ListingPage.js
+++ b/src/containers/ListingPage/ListingPage.js
@@ -575,7 +575,11 @@ export class ListingPageComponent extends Component {