0.0.8 • Published 5 years ago
@spikkl/spikkl-geo-js v0.0.8
Javascript Client for Spikkl Geo API
The Spikkl Geo Client for javascript lets you easily use the Spikkl API from your javascript code.
Installation
You can either use a package manager like npm.
When you use npm as your package manager:
$ npm install @spikkl/spikkl-geo-js
When you use yarn as your package manager:
$ yarn add @spikkl/spikkl-geo-js
Usage
Configuring the SDK for your app
Create and get your app key from the Spikkl Dashboard. Use your app key to create a new Spikkl instance:
const Spikkl = require('@spikkl/spikkl-geo-js');
let spikkl = new Spikkl({
appKey: 'YOUR_APP_KEY'
});
Location
Once your have created your Spikkl instance, you can immediately Retrieve a location based on a postal code, house number, and house number suffix.
spikkl.location({
postalCode: '2611HB',
number: '175',
suffix: ''
}).then( (response) => {
console.log('Your requested location:', response.data[0]);
}).catch( (error) => {
console.log('Error:', error);
});
Reverse
You can retrieve an address or location based on a latitude and longitude value:
spikkl.location({
latitude: 52.0121329,
longitude: 4.3549009
}).then( (response) => {
console.log('Your requested address:', response.data[0]);
}).catch( (error) => {
console.log('Error:', error);
});
Search
If you do not have a postal code available for retrieving an address, try using as search query containing a street name, house number and a city.
spikkl.search({
query: 'Oude Delft 175 Delft'
}).then( (response) => {
console.log('Your requested address:', response.data[0]);
}).catch( (error) => {
console.log('Error:', error);
});