Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
}
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 }) => (
handleSelect = (address) => {
geocodeByAddress(address)
.then(results => this.props.updateSearchResultViewport(results[0].geometry.viewport))
.catch(error => console.error('Error', error));
}
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))
}
}
const latLngevt = address => (
geocodeByAddress(address)
.then(results => getLatLng(results[0]))
.catch(err => console.log(err))
);
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
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
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 })
})
}
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,
});
}
};