Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(results => {
console.log(results)
getLatLng(results[0])
})
.then(latLng => console.log('Success', latLng))
.then(results => {
//console.log(results);
addr = results[0].formatted_address;
this.setState({ address: addr });
return getLatLng(results[0]);
})
.then(results => {
handleLocationChange = async (address, id) => {
const place = await geocodeByPlaceId(id);
this.setState(
{
city: place[0].formatted_address,
location: await getLatLng(place[0]),
},
this.search,
);
};
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);
}
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);
}
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);
};
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();
};
.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 => {