ng2-haversine
Advanced tools
Comparing version 0.0.6 to 0.1.0
{ | ||
"name": "ng2-haversine", | ||
"version": "0.0.6", | ||
"version": "0.1.0", | ||
"description": "An Angular 2 library to calculate the distance between a pair of coordinates using the Haversine formula.", | ||
@@ -19,3 +19,4 @@ "repository": { | ||
"scripts": { | ||
"tsc": "rm -rf ./dist && tsc", | ||
"clean": "node ./src/clean.js", | ||
"tsc": "tsc", | ||
"typings": "typings" | ||
@@ -29,3 +30,4 @@ }, | ||
"devDependencies": { | ||
"@angular/core": "^2.0.1", | ||
"@angular/core": "^2.0.2", | ||
"rimraf": "^2.5.4", | ||
"rxjs": "^5.0.0-beta.12", | ||
@@ -32,0 +34,0 @@ "typescript": "^2.0.3", |
# ng2-haversine | ||
[![NPM](https://nodei.co/npm/ng2-haversine.png?compact=true)](https://nodei.co/npm/ng2-haversine/) | ||
[![npm version](https://badge.fury.io/js/ng2-haversine.svg)](https://badge.fury.io/js/ng2-haversine) [![Dependency Status](https://david-dm.org/vermicida/ng2-haversine.svg)](https://david-dm.org/vermicida/ng2-haversine) | ||
An Angular 2 library to calculate the distance between a pair of coordinates using the Haversine formula. | ||
## Getting started | ||
Install `ng2-haversine` using `npm` within your Angular 2 app directory: | ||
```bash | ||
$ npm instal ng2-haversine --save | ||
``` | ||
Once the package is installed, set the provider for `HaversineService` in your `AppModule`: | ||
```typescript | ||
import { HaversineService } from "ng2-haversine"; | ||
@NgModule({ | ||
... | ||
providers: [HaversineService] | ||
... | ||
}) | ||
export class AppModule { } | ||
``` | ||
Now you're ready to use `ng2-haversine`! | ||
## How to | ||
You can use `HaversineService` from a Service or from a Component: just inject it as a dependency. Remember to import `GeoCoord` as well: | ||
```typescript | ||
import { HaversineService, GeoCoord } from "ng2-haversine"; | ||
@Component({ ... }) | ||
export class MyComponent { | ||
constructor(private _haversineService: HaversineService) { } | ||
} | ||
``` | ||
Then, use some of the provided functions in `HaversineService` to calcule the distance between two points: | ||
```typescript | ||
tryHaversine(): void { | ||
let madrid: GeoCoord = { | ||
latitude: 40.416775, | ||
longitude: -3.703790 | ||
}; | ||
let bilbao: GeoCoord = { | ||
latitude: 43.262985, | ||
longitude: -2.935013 | ||
}; | ||
let meters = this._haversineService.getDistanceInMeters(madrid, bilbao); | ||
let kilometers = this._haversineService.getDistanceInKilometers(madrid, bilbao); | ||
let miles = this._haversineService.getDistanceInMiles(madrid, bilbao); | ||
console.log(` | ||
The distance between Madrid and Bilbao is: | ||
- ${meters} meters | ||
- ${kilometers} kilometers | ||
- ${miles} miles | ||
`); | ||
} | ||
``` | ||
## Using SystemJS | ||
To load `ng2-haversine` using [SystemJS](https://github.com/systemjs/systemjs) is as simple as this. Open your `systemjs.config.js` file and set `map` and `packages` properties this way: | ||
```javascript | ||
(function (global) { | ||
System.config({ | ||
map: { | ||
... | ||
"ng2-haversine": "npm:ng2-haversine" | ||
}, | ||
packages: { | ||
... | ||
"ng2-haversine": { | ||
main: "./index.js", | ||
defaultExtension: "js" | ||
} | ||
} | ||
}); | ||
})(this); | ||
``` | ||
That's it :) | ||
## License | ||
Code released under the [MIT license](./LICENSE). |
@@ -1,7 +0,7 @@ | ||
import { GeoCoord } from "./models/geo-coord"; | ||
import { HaversineService } from "./services/haversine.service"; | ||
import { GeoCoord } from "./geo-coord"; | ||
import { HaversineService } from "./haversine.service"; | ||
export * from "./models/geo-coord"; | ||
export * from "./services/haversine.service"; | ||
export default { providers: [HaversineService] } | ||
export { | ||
GeoCoord, | ||
HaversineService | ||
} |
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"outDir": ".", | ||
"target": "es5", | ||
@@ -10,3 +10,3 @@ "module": "commonjs", | ||
"experimentalDecorators": true, | ||
"removeComments": false, | ||
"removeComments": true, | ||
"noImplicitAny": true, | ||
@@ -16,9 +16,9 @@ "declaration": true | ||
"files": [ | ||
"typings/index.d.ts", | ||
"src/index.ts" | ||
"./typings/index.d.ts", | ||
"./src/index.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
"./src/clean.js" | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
37471
22
0
96
6
745
1