0.1.1 • Published 2 years ago
@brandensmith_/react-native-geocode v0.1.1
@brandensmith_/react-native-geocode
A NativeModule to interact with native Geocode APIs in React Native
Installation
npm install @brandensmith_/react-native-geocode
Usage
import {
getAddressFromGeopoint,
getCoordinateFromAddressString,
} from '@brandensmith_/react-native-geocode';
// ...
const [currentAddress, setAddress] = React.useState < string > 'none';
const [currentGeopoint, setGeopoint] = React.useState < string > 'none';
const getAddress = () => {
getAddressFromGeopoint({
latitude: 37.331656,
longitude: -122.0301426,
})
.then((address) => {
setAddress(
`${address.street1}\n${address.city}, ${address.state} ${address.postalCode}\n${address.country}`
);
})
.catch((error) => {
console.log(error);
});
};
const getGeopoint = () => {
getCoordinateFromAddressString('1 infinite Loop, Cupertino, CA')
.then((geopoint) => {
setGeopoint(`Lat: ${geopoint.latitude}, Long: ${geopoint.longitude}`);
})
.catch((error) => {
console.log(error);
});
};
// ...
Contributing
See the contributing guide to learn how to contribute to the repository and the development workflow.
License
MIT