Neoteric Plumbing Mishap
Join us to discuss the challenges, solutions and best practices for in-house JavaScript code sharing. Tuesday, 12/17 at 10am PT/1pm ET.Sign up here »

smart-geo

0.1.8 • Public • Published

Smart Geo

Build Status Code Climate Dependency Status devDependency Status npm downloads npm version Join the chat at https://gitter.im/smart-io/js-geo

Smart Geo is data from Open Data providers compiled into easy to use JavaScript objects.

Table Of Content

  1. Features
  2. Sources
  3. Requirements
  4. Installation
  1. Country
  2. Region
  3. License
## Features
  • Multiple languages (Currently only supports English, French and German).
  • Country Database
  • Region Database (Currently only for Canada and the United States).
## Sources ## Requirements

Smart Geo does not require a database, but instead, uses JSON files.

## Installation ### Installation with npm
npm install smart-geo
### Installation with Bower
bower install smart-geo
## Country

Database of all countries in the world.

Properties

  • Names
  • Short Code (Alpha-2 code)
  • Code (Alpha-3 code)
  • Latitude
  • Longitude
  • Bounding Box
  • Currency
  • Continent
  • Population
  • Area
  • Capital
  • Timezone

Examples

Get a list of all countries.

var geo = require('smart-geo');
 
var countries = geo.countryRepository.findAll();
console.log(countries);

Get a country name in english or othe languages.

var geo = require('smart-geo');
 
var country = geo.countryRepository.findByShortCode('US');
console.log(country.get('name'));
console.log(country.get('name', 'fr'));

Order by country name in any language.

var geo = require('smart-geo');
 
var countries = geo.countryRepository.findAll();
countries.orderByName('de');
console.log(countries);
## Region

Database of all States, Federal Districts and Territories in the United States, Provinces and Territories in Canada.

Properties

  • Name
  • Code (Alpha-2 code)
  • Country
  • Type
  • Latitude
  • Longitude
  • Bounding Box

Examples

Get a list of all regions in the US.

var geo = require('smart-geo');
 
var country = geo.countryRepository.findByShortCode('US');
console.log(country.get('regions'));

Get region name and type in english.

var geo = require('smart-geo');
 
var regions = geo.regionRepository.findAll();
for (var i = 0, len = regions.length; i < len; ++i) {
  console.log(
    regions[i].get('name') + " is a " + 
    regions[i].get('type') + " of the " +
    regions[i].get('country').get('name')
  );
}
## License

Smart Geo is licensed under The MIT License (MIT).

Install

npm i smart-geo

DownloadsWeekly Downloads

0

Version

0.1.8

License

MIT

Last publish

Collaborators

  • avatar