From 760d0cc3c2f6dcaf2237feecf56d2326812cc504 Mon Sep 17 00:00:00 2001 From: Kimmo Puputti Date: Wed, 7 Feb 2018 14:47:20 +0200 Subject: [PATCH] Improve coordinate obfuscation configuration --- src/config.js | 22 ++++++++++++++++--- .../__snapshots__/SearchPage.test.js.snap | 2 ++ src/util/maps.js | 7 +++--- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/config.js b/src/config.js index 138ee757..663d9596 100644 --- a/src/config.js +++ b/src/config.js @@ -241,18 +241,34 @@ 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 || false, + fuzzy: false, + // Default zoom level when showing a single circle on a Map. Should + // be small enough so the whole circle fits in. fuzzyDefaultZoomLevel: 14, - // When fuzzy === true, a circle is shown on the map, the radius and - // the style can be configured here. + // When fuzzy === true, the coordinates on the Map component are + // obfuscated and a circle is shown instead of a marker. To decide a + // proper value for the offset and the radius, see: + // + // https://gis.stackexchange.com/a/8674 + + // Amount of maximum offset that is applied to obfuscate the + // original coordinates. + coordinateOffset: 0.004, // 0.001 is roughly 111m + + // The circle radius in meters. circleRadius: 500, + + // Options to style the circle appearance. + // + // See: https://developers.google.com/maps/documentation/javascript/reference#CircleOptions circleOptions: { fillColor: '#c0392b', fillOpacity: 0.2, strokeColor: '#c0392b', strokeWeight: 0.5, + clickable: false, }, }; diff --git a/src/containers/SearchPage/__snapshots__/SearchPage.test.js.snap b/src/containers/SearchPage/__snapshots__/SearchPage.test.js.snap index fb1ecae0..14f11b5d 100644 --- a/src/containers/SearchPage/__snapshots__/SearchPage.test.js.snap +++ b/src/containers/SearchPage/__snapshots__/SearchPage.test.js.snap @@ -156,12 +156,14 @@ exports[`SearchPageComponent matches snapshot 1`] = ` coordinatesConfig={ Object { "circleOptions": Object { + "clickable": false, "fillColor": "#c0392b", "fillOpacity": 0.2, "strokeColor": "#c0392b", "strokeWeight": 0.5, }, "circleRadius": 500, + "coordinateOffset": 0.004, "fuzzy": false, "fuzzyDefaultZoomLevel": 14, } diff --git a/src/util/maps.js b/src/util/maps.js index a5440366..abff5bcc 100644 --- a/src/util/maps.js +++ b/src/util/maps.js @@ -1,13 +1,14 @@ import { random, memoize, round } from 'lodash'; import { types as sdkTypes } from './sdkLoader'; +import config from '../config'; const { LatLng } = sdkTypes; const obfuscatedCoordinatesImpl = latlng => { const { lat, lng } = latlng; - const threshold = 0.01; - const newLat = round(lat + random(-1 * threshold, threshold), 5); - const newLng = round(lng + random(-1 * threshold, threshold), 5); + const offset = config.coordinates.coordinateOffset; + const newLat = round(lat + random(-1 * offset, offset), 5); + const newLng = round(lng + random(-1 * offset, offset), 5); return new LatLng(newLat, newLng); };