├── CHANGELOG.md
├── Geocoder.js
├── LICENSE
├── README.md
├── index.d.ts
└── package.json
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Release Notes
2 |
3 | ### 0.4.0
4 |
5 | - Fixed fetching options
6 | - Removed deprecated code
7 |
8 | ### 0.3.0
9 |
10 | - Documented functions and errors
11 | - Only one function to use now
12 |
13 | ### 0.2.0
14 |
15 | - Reverse geocoding
16 |
17 | ### 0.1.0
18 |
19 | - Initial release
--------------------------------------------------------------------------------
/Geocoder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Module to use google's geocoding & reverse geocoding.
3 | */
4 | let Geocoder;
5 | export default Geocoder = {
6 | apiKey : null,
7 | options : {},
8 |
9 | /**
10 | * Initialize the module.
11 | * @param {String} apiKey The api key of your application in google.
12 | * @param {Object} [options] extra options for your geocoding request.
13 | * @see https://developers.google.com/maps/documentation/geocoding/intro#geocoding
14 | */
15 | init(apiKey, options = {}) {
16 | this.apiKey = apiKey;
17 | this.options = options;
18 | },
19 |
20 | /**
21 | * @returns {boolean} True if the module has been initiated. False otherwise.
22 | */
23 | get isInit() {
24 | return !!this.apiKey;
25 | },
26 |
27 | /**
28 | * Do (reverse) geocoding, converting geographic coordinates into a human-readable address & vice-versa.
29 | * Accepted parameters:
30 | *
31 | * - from(Number latitude, Number longitude)
32 | * - from(Array [latitude, longitude])
33 | * - from(Object {latitude, longitude})
34 | * - from(Object {lat, lng})
35 | * - from(String address)
36 | *
37 | * @returns {Promise.