How to use the react-places-autocomplete.geocodeByAddress function in react-places-autocomplete

To help you get started, we’ve selected a few react-places-autocomplete examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prabeen04 / ant-dashboard / src / components / google / googlePlace.js View on Github external
const handleSelect = (address) => {
        props.setGoogleAddress(address)
        geocodeByAddress(address)
            .then(results => {
                console.log(results)
                getLatLng(results[0])
            })
            .then(latLng => console.log('Success', latLng))
            .catch(error => console.error('Error', error))
    }
github prabeen04 / ant-dashboard / src / container / forms / reuseForm.js View on Github external
const handleSelect = address => {
        console.log(props, address)
        geocodeByAddress(address)
            .then(results => getLatLng(results[0]))
            .then(latLng => {
                console.log('Success', latLng)
                setLatlng(latLng)
            })
            .then(() => props.change('location', address))
            .catch(error => console.error('Error', error));
    };
    const renderInput = ({ input, meta, width, label, ...custom }) => (
github letsdoitworld / World-Cleanup-Day / web-app / src / components / Events / EventListHeader.js View on Github external
handleSelect = (address) => {
    geocodeByAddress(address)
      .then(results => this.props.updateSearchResultViewport(results[0].geometry.viewport))
      .catch(error => console.error('Error', error));
  }
github focallocal / fl-maps / imports / client / ui / components / PlacesSearchBox / index.js View on Github external
handleSelect = (address) => {
    const { onSelect } = this.props

    if (!onSelect) {
      return
    }

    geocodeByAddress(address)
      .then(results => getLatLng(results[0]))
      .then(latLng => onSelect({ ...latLng, name: address }))
      .catch(error => console.error('Error', error))
  }
}
github Henriettas-Army / CodeUp / client / src / containers / MapData.jsx View on Github external
const latLngevt = address => (
  geocodeByAddress(address)
    .then(results => getLatLng(results[0]))
    .catch(err => console.log(err))
);
github poanetwork / poa-dapps-voting / src / components / Validator / index.js View on Github external
onSelectAutocomplete = async data => {
    const { validatorStore } = this.props
    let place = await geocodeByAddress(data)
    let address_components = {
      postal_code: '',
      street_number: '',
      route: '',
      locality: '',
      administrative_area_level_1: ''
    }

    for (let i = 0; i < place[0].address_components.length; i++) {
      let address_component = place[0].address_components[i]
      let addressType = address_component.types[0]

      switch (addressType) {
        case 'postal_code':
          address_components.postal_code = address_component.short_name
          break
github poanetwork / poa-dapps-validators / src / App.js View on Github external
async onSelectAutocomplete(data) {
    let place = await geocodeByAddress(data)
    let address_components = {}
    for (var i = 0; i < place[0].address_components.length; i++) {
      var addressType = place[0].address_components[i].types[0]
      switch (addressType) {
        case 'postal_code':
          address_components.postal_code = place[0].address_components[i].short_name
          break
        case 'street_number':
          address_components.street_number = place[0].address_components[i].short_name
          break
        case 'route':
          address_components.route = place[0].address_components[i].short_name
          break
        case 'locality':
          address_components.locality = place[0].address_components[i].short_name
          break
github onevote / onevote / components / distance.js View on Github external
componentDidMount() {
    const { from, to } = this.props
    Promise.all([geocodeByAddress(from), geocodeByAddress(to)])
      .then(results => Promise.all(results.map(result => getLatLng(result[0]))))
      .then(([from, to]) => {
        this.setState({ from, to })
      })
  }
github deens-com / frontend / src / styled_scenes / Results / index.js View on Github external
updateCenter = async (formattedAddress, countryCode, state, city) => {
    this.setState({
      updatingCenter: true,
    });
    const cityStr = city ? `${city}, ` : '';
    const stateStr = state ? `${state}, ` : '';
    const address = formattedAddress || `${cityStr}${stateStr}${countryCode}`;

    await waitUntilMapsLoaded();
    const results = await geocodeByAddress(address);
    const center = await getLatLng(results[0]);
    if (this.state.updatingCenter) {
      this.setState({
        center,
      });
    }
  };

react-places-autocomplete

A React component for Google Maps Places Autocomplete

MIT
Latest version published 4 years ago

Package Health Score

61 / 100
Full package analysis