Check if a Lat/Lng Coordinate is within a specific Canadian Province or Territory
npm install within-canadaCheck if a Lat/Lng Coordinate is within the specified Canadian Province or Territory.
``js
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:
`js
// 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.
The following functions are available, where lat and lng are of type Number:
- on(lat, lng) returns true if the point is within Ontarioab(lat, lng)
- returns true if the point is within Albertabc(lat, lng)
- returns true if the point is within British Columbianl(lat, lng)
- returns true if the point is within Newfoundland and Labradorpe(lat, lng)
- returns true if the point is within Prince Edward Islandns(lat, lng)
- returns true if the point is within Nova Scotianb(lat, lng)
- returns true if the point is within New Brunswickqc(lat, lng)
- returns true if the point is within Québecmb(lat, lng)
- returns true if the point is within Manitobask(lat, lng)
- returns true if the point is within Saskatchewanyt(lat, lng)
- returns true if the point is within Yukon Territorynt(lat, lng)
- returns true if the point is within Northwest Territoriesnu(lat, lng)
- returns true` if the point is within Nunavut