Get the U.S. state closest to the user's position. Compares lat/lon coordinates from a Position
object to the centroid of each U.S. state. Favors speed over accuracy.
Locations near a state's border may return an incorrect, neighboring state. If accuracy is important, you should use a third-party reverse geocoding API (e.g. Google's).
Installation
First install node.js. Then:
npm install fuzzy-state-search --save
Usage
Require the module and pass it a Position
object:
var getState = ; { var state = ; console;}; // Get their coordinates using the HTML5 geolocation API.navigatorgeolocation;
Contributing
Please read the Contributing guidelines.
Running Tests
We are using nodeunit to test. To run tests, first install nodeunit and any dependencies via npm:
npm install
Run tests with:
npm test