Extract the geocoding attribution to the geocoder file

This commit is contained in:
Kimmo Puputti 2018-08-09 14:53:31 +03:00
parent 98f4e49513
commit f92c3bdeb2
3 changed files with 12 additions and 9 deletions

View file

@ -1,5 +1,13 @@
import React from 'react';
import { getPlacePredictions, getPlaceDetails } from '../../util/googleMaps';
import css from './LocationAutocompleteInput.css';
// When displaying data from the Google Maps Places API, and
// attribution is required next to the results.
// See: https://developers.google.com/places/web-service/policies#powered
export const GeocoderAttribution = () => <div className={css.poweredByGoogle} />;
/**
* A forward geocoding (place name -> coordinates) implementation
* using the Google Maps Places API.

View file

@ -24,6 +24,8 @@ const placeBounds = prediction => {
return null;
};
export const GeocoderAttribution = () => null;
/**
* A forward geocoding (place name -> coordinates) implementation
* using the Mapbox Geocoding API.

View file

@ -3,17 +3,10 @@ import { any, arrayOf, bool, func, number, shape, string, oneOfType, object } fr
import classNames from 'classnames';
import debounce from 'lodash/debounce';
import { propTypes } from '../../util/types';
import Geocoder from './GeocoderGoogleMaps';
import Geocoder, { GeocoderAttribution } from './GeocoderGoogleMaps';
import css from './LocationAutocompleteInput.css';
// When using the Google Maps Places API for geocoding, a "Powered by
// Google" logo should be shown next to the results. Turn this to
// `false` when using some other Geocoding API. Autocomplete
// predictions dropdown bottom padding might need adjusting as well to
// hide the space left for the logo.
const SHOW_POWERED_BY_GOOGLE = true;
const DEBOUNCE_WAIT_TIME = 200;
const KEY_CODE_ARROW_UP = 38;
const KEY_CODE_ARROW_DOWN = 40;
@ -94,7 +87,7 @@ const LocationPredictionsList = props => {
return (
<div className={classes}>
<ul className={css.predictions}>{predictions.map(item)}</ul>
{SHOW_POWERED_BY_GOOGLE ? <div className={css.poweredByGoogle} /> : null}
<GeocoderAttribution />
</div>
);
};