within-canada
v1.0.0
Published
Check if a Lat/Lng Coordinate is within a specific Canadian Province or Territory
Downloads
40
Readme
within-canada
Check if a Lat/Lng Coordinate is within the specified Canadian Province or Territory.
Examples
import canada from 'within-canada';
const toronto = { lat: 43.6532, lng: -79.3832 };
// Check for Toronto within Ontario (ON)
canada.on(toronto.lat, toronto.lng);
// true
However, it is much more space efficient to only request the function for the province/territory you actually need:
// get only the on() function (on its own)
import ontario from 'within-canada/on'
const toronto = { lat: 43.6532, lng: -79.3832 };
on(toronto.lat, toronto.lng);
// true
Each province/territory is available using the two character region code listed below.
API
The following functions are available, where lat
and lng
are of type Number
:
on(lat, lng)
returnstrue
if the point is within Ontarioab(lat, lng)
returnstrue
if the point is within Albertabc(lat, lng)
returnstrue
if the point is within British Columbianl(lat, lng)
returnstrue
if the point is within Newfoundland and Labradorpe(lat, lng)
returnstrue
if the point is within Prince Edward Islandns(lat, lng)
returnstrue
if the point is within Nova Scotianb(lat, lng)
returnstrue
if the point is within New Brunswickqc(lat, lng)
returnstrue
if the point is within Québecmb(lat, lng)
returnstrue
if the point is within Manitobask(lat, lng)
returnstrue
if the point is within Saskatchewanyt(lat, lng)
returnstrue
if the point is within Yukon Territorynt(lat, lng)
returnstrue
if the point is within Northwest Territoriesnu(lat, lng)
returnstrue
if the point is within Nunavut