Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function codeAddress(address) {
- const fetchAddress = (resolve) => {
- const geocoder = new google.maps.Geocoder();
- const parseResult = (results, status) => {
- if (status !== google.maps.GeocoderStatus.OK) {
- resolve([])
- return;
- }
- resolve([
- results[0].geometry.location.lat(),
- results[0].geometry.location.lng()
- ]);
- };
- geocoder.geocode({ address: address, language: 'english' }, parseResult);
- }
- return new Promise(fetchAddress);
- }
- // uzycie
- codeAddress('address').then(result => {
- console.log(result)
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement