0.1.8 • Published 9 years ago

smart-geo v0.1.8

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

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
  • Multiple languages (Currently only supports English, French and German).
  • Country Database
  • Region Database (Currently only for Canada and the United States).

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

npm install smart-geo
bower install smart-geo

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);

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')
  );
}

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

0.1.8

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago