How to use the react-places-autocomplete.getLatLng 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
.then(results => {
                console.log(results)
                getLatLng(results[0])
            })
            .then(latLng => console.log('Success', latLng))
github deens-com / frontend / src / styled_scenes / Results / components / SearchFilters.js View on Github external
.then(results => {
        //console.log(results);
        addr = results[0].formatted_address;
        this.setState({ address: addr });
        return getLatLng(results[0]);
      })
      .then(results => {
github deens-com / frontend / src / styled_scenes / TripOrganizer / AddServiceModal.js View on Github external
handleLocationChange = async (address, id) => {
    const place = await geocodeByPlaceId(id);

    this.setState(
      {
        city: place[0].formatted_address,
        location: await getLatLng(place[0]),
      },
      this.search,
    );
  };
github codexstanford / techlist-frontend-web / src / apps / admin / routes / company / location.js View on Github external
async function handleSelection(suggestion) {
    const latlng = await getLatLng(suggestion);
    const { geometry } = suggestion;
    const { location } = geometry;
    const newLocation = Object.assign({}, location, {
      set: { location: { ...latlng } },
      lat: null,
      lng: null,
    });
    const newGeo = Object.assign({}, geometry, { ...newLocation });
    const result = Object.assign({}, suggestion, { geometry: { ...newGeo } });
    props.setFieldValue('locationjson', result, false);
  }
github codexstanford / techlist-frontend-web / src / apps / admin / features / company.create / components / location / address.js View on Github external
async function handleSelection(suggestion) {
    const latlng = await getLatLng(suggestion);
    const { geometry } = suggestion;
    const { location } = geometry;
    const newLocation = Object.assign({}, location, {
      set: { location: { ...latlng } },
      lat: null,
      lng: null,
    });
    const newGeo = Object.assign({}, geometry, { ...newLocation });
    const result = Object.assign({}, suggestion, { geometry: { ...newGeo } });
    props.setFieldValue('locationjson', result, false);
  }
github deens-com / frontend / src / styled_scenes / Trips / components / ToolBar / OwnerToolBar.js View on Github external
onLocationSelect = async (address, placeId) => {
    const { onValueChange } = this.props;
    onValueChange('formattedAddress', address);
    const results = await geocodeByPlaceId(placeId);
    const currentResult = results[0];
    const latlngPromise = getLatLng(currentResult);
    const { address_components: addressComponents } = currentResult;
    const localities = addressComponents.filter(
      c => c.types.includes('locality') || c.types.includes('postal_town'),
    );
    const countries = addressComponents.filter(c => c.types.includes('country'));
    if (countries[0] && countries[0].long_name) {
      onValueChange('country', countries[0].long_name);
    }
    if (localities[0] && localities[0].long_name) {
      onValueChange('city', localities[0].long_name);
    }
    const latlng = await latlngPromise;
    onValueChange('latlng', latlng);
  };
github deens-com / frontend / src / styled_scenes / EditTrip / components / ToolBar / EditTripForm.js View on Github external
onLocationChange = async (address, placeId) => {
    if (!address || !placeId) return;
    const { setFieldValue, submitForm } = this.props;
    setFieldValue('formattedAddress', address);
    const results = await geocodeByPlaceId(placeId);
    const currentResult = results[0];
    const latlngPromise = getLatLng(currentResult);
    const { address_components: addressComponents } = currentResult;
    const localities = addressComponents.filter(
      c => c.types.includes('locality') || c.types.includes('postal_town'),
    );
    const countries = addressComponents.filter(c => c.types.includes('country'));
    if (countries[0] && countries[0].long_name) {
      setFieldValue('country', countries[0].long_name);
    }
    if (localities[0] && localities[0].long_name) {
      setFieldValue('city', localities[0].long_name);
    }
    const latlng = await latlngPromise;
    setFieldValue('latlng', latlng);
    submitForm();
  };
github deens-com / frontend / src / shared_components / ServiceForm / index.js View on Github external
.then(results => {
        const currentResult = results[0];
        const latlngPromise = getLatLng(currentResult);
        setFieldValue('formattedAddress', currentResult.formatted_address);
        const { address_components: addressComponents } = currentResult;
        const localities = addressComponents.filter(
          c => c.types.includes('locality') || c.types.includes('postal_town'),
        );
        const countries = addressComponents.filter(c => c.types.includes('country'));
        if (countries[0] && countries[0].long_name) {
          setFieldValue('country', countries[0].long_name);
        }
        if (localities[0] && localities[0].long_name) {
          setFieldValue('city', localities[0].long_name);
        }
        return latlngPromise;
      })
      .catch(err => {

react-places-autocomplete

A React component for Google Maps Places Autocomplete

MIT
Latest version published 4 years ago

Package Health Score

58 / 100
Full package analysis