Use the supplied geolocations in locations.json
to experiment with geolib
.
Take a look at the geolib module on GitHub.
Be sure to reference it before you use it:
<!-- be sure the src path is correct -->
<script src="geolib.min.js" charset="utf-8"></script>
Install the module like this:
npm install geolib --save
The --save
adds it to your package.json
. If you don't have one already, you can use npm init
to add one.
The geolib functions returns results like this:
geolib.getSpeed(
{lat: 51.567294, lng: 7.38896, time: 1360231200880},
{lat: 52.54944, lng: 13.468509, time: 1360245600880},
{unit: 'mph'}
);
// -> 66.9408 (mph)
You should use the results of the function:
var speed = geolib.getSpeed(
{lat: 51.567294, lng: 7.38896, time: 1360231200880},
{lat: 52.54944, lng: 13.468509, time: 1360245600880},
{unit: 'mph'}
);
// -> 66.9408 (mph)
console.log(speed);
Use the supplied app.js
file to experiment with geolib in the browser. All the references are set up correctly in the index.html
file.
There are two utility functions:
- one to handle displaying text in the results
div
calledprint
- one to handle button
click
button events calledclickButton
.