This library is deprecated, use geobase/countries instead.
Smart Geo is data from Open Data providers compiled into easy to use JavaScript objects.
## Features- 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.
## Installation ### Installation with npmnpm 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).