Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8f37d35
add `edgeScale` option
Raruto Apr 17, 2023
a3d7bcf
prevent multiple control instantiations
Raruto Apr 17, 2023
8f10ef8
add `leaflet-elevation_edge-scale.html`
Raruto Apr 17, 2023
63ad29a
update examples
Raruto Apr 17, 2023
3462a03
update versions
Raruto Apr 17, 2023
f6051d3
workaround when "rotate: true"
Raruto Apr 17, 2023
81f18b0
update default option
Raruto Apr 17, 2023
d68ae9a
Update leaflet-elevation_edge-scale.html
Raruto Apr 17, 2023
bdebae3
update dev dependencies
Raruto Apr 18, 2023
88cfa11
setup some `e2e` tests
Raruto Apr 19, 2023
4100243
Update leaflet-elevation.spec.ts
Raruto Apr 19, 2023
879f54c
fix warning
Raruto Apr 19, 2023
5084824
add test case for: https://github.com/Raruto/leaflet-elevation/issues…
Raruto Apr 20, 2023
1a201ee
comments
Raruto Apr 20, 2023
3f7f4cd
sample tests integration: `uvu` + `playwright`
Raruto Apr 21, 2023
04f3b11
remove extra parameters
Raruto Apr 21, 2023
a65a3dd
remove `e2e` folder
Raruto Apr 21, 2023
9cbcd04
delete `spec` folder
Raruto Apr 21, 2023
b2c4068
add test case for: https://github.com/Raruto/leaflet-elevation/issues…
Raruto Apr 23, 2023
85ba485
make use of abortcontroller to ensure killing of http server
Raruto Apr 23, 2023
8a618bd
add default `timeout` to uvu tests
Raruto Apr 23, 2023
6479a02
Create leaflet-elevation_edge-scale.spec.js
Raruto Apr 23, 2023
24aac77
update tests
Raruto Apr 23, 2023
03b2cff
update how develop instructions
Raruto Apr 23, 2023
ea73530
Update leaflet-elevation_multiple-maps.spec.js
Raruto Apr 23, 2023
457d983
Update leaflet-elevation_multiple-maps.html
Raruto Apr 23, 2023
59fb6d7
add clear button example
Raruto Apr 23, 2023
0931ace
add test file
Raruto Apr 23, 2023
f9a1635
Update leaflet-elevation_clear-button.spec.js
Raruto Apr 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ spec/**/*.min.js
src/**/*.min.js
src/**/*.min.css
dist/
e2e/results/
e2e/reports/
/playwright/.cache/
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ _For a working example see one of the following demos:_

- [autohide map](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-map.html)
- [autohide chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-chart.html)
- [clear button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_clear-button.html)
- [collapsible button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_close-button.html)
- [custom summary](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-summary.html)
- [edge scale control](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_edge-scale.html)
- [follow marker](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_follow-marker.html)
- [layer almostover](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_almost-over.html)
- [slope chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_slope-chart.html)
Expand Down Expand Up @@ -153,6 +155,9 @@ _For a working example see one of the following demos:_

// Toggle "leaflet-distance-markers" integration
distanceMarkers: false,

// Toggle "leaflet-edgescale" integration
edgeScale: false,

// Toggle "leaflet-hotline" integration
hotline: true,
Expand Down Expand Up @@ -195,19 +200,19 @@ _For a working example see one of the following demos:_

### Build Guide

For those wishing to try cloning this repository into a local development folder (eg. /var/www):
Within your local development environment:

```shell
git clone [email protected]:Raruto/leaflet-elevation.git
cd ./leaflet-elevation

npm i # install dependencies
npm run watch # auto-generate "dist" files
npm run dev # start dev server at: http://localhost:8080
npm run build # generate "dist" files (once)
npm run test # test "spec" files (once)
npm run test # test all ".*spec.js" files (once)
```

After that you can start developing inside the `src` and `test` folders (eg. open "http://localhost/leaflet-elevation/test" in your browser to preview changes). Check also [CONTRIBUTING.md](.github/CONTRIBUTING.md) file for some information about it.
After that you can start developing inside the `src` and `test` folders (eg. open "http://localhost:8080/test" in your browser to preview changes). Check also [CONTRIBUTING.md](.github/CONTRIBUTING.md) file for some information about it.

### FAQ

Expand Down
15 changes: 8 additions & 7 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { terser } from "rollup-plugin-terser";
import resolve from 'rollup-plugin-node-resolve';
import commonJS from 'rollup-plugin-commonjs';
import terser from '@rollup/plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import commonJS from '@rollup/plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import postcssImport from 'postcss-import';

// import postcssCopy from 'postcss-copy';
import rollupGitVersion from 'rollup-plugin-git-version';
// import rollupGitVersion from 'rollup-plugin-git-version';

import plugin from '../package.json' assert { type: "json" };

let plugin = require('../package.json');
let plugin_name = plugin.name.replace("@raruto/", "");

let input = plugin.module;
Expand All @@ -15,15 +17,14 @@ let output = {
format: "umd",
sourcemap: true,
name: plugin_name,

};

let plugins = [
resolve(),
commonJS({
include: '../node_modules/**'
}),
rollupGitVersion(),
// rollupGitVersion(),
];

export default [
Expand Down
4 changes: 2 additions & 2 deletions examples/leaflet-elevation.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>

<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.js"></script>

</head>

Expand Down
19 changes: 19 additions & 0 deletions examples/leaflet-elevation.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* examples/leaflet-elevation.html
*/

import * as assert from 'uvu/assert';
import { suite } from '../test/setup/http_server.js';

const test = suite('examples/leaflet-elevation.html');

test('eledata_loaded', async ({ page }) => {
const gpx = await page.evaluate(() => new Promise(resolve => {
controlElevation.on('eledata_loaded', (gpx) => resolve(gpx));
}));
assert.is(gpx.name, 'via-emilia.gpx');
assert.not.type(gpx.layer, 'undefined');
assert.type(gpx.track_info.distance, 'number');
});

test.run();
4 changes: 2 additions & 2 deletions examples/leaflet-elevation_almost-over.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
plugins: [
// '[email protected]/src/leaflet.geometryutil.js',
// '[email protected]/src/leaflet.almostover.js',
'@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.css',
'@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.js'
'@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.css',
'@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.js'
],
// see: L.AlmostOver for more info
almostOver: true,
Expand Down
137 changes: 137 additions & 0 deletions examples/leaflet-elevation_clear-button.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<!DOCTYPE html>
<html>

<head>
<title>leaflet-elevation.js</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="dns-prefetch" href="https://tile.openstreetmap.org">
<link rel="dns-prefetch preconnect" href="https://unpkg.com" />
<link rel="preload" href="https://unpkg.com/[email protected]/dist/leaflet.js" as="script">
<link rel="preload" href="https://unpkg.com/[email protected]/dist/leaflet-ui.js" as="script">

<style>
@import '../libs/fullpage.css';
</style>

<!-- leaflet-ui -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>

<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/[email protected]/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/[email protected]/dist/leaflet-elevation.min.js"></script>

<style>
button {
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
font-family: monospace;
}
.update {
background-color: #4CAF50;
}
.toggle {
background-color: #ffa500;
}
.reset {
background-color: #f44336;
}
</style>
</head>

<body>

<div id="map" class="leaflet-map"></div>
<div style="position: fixed; inset: auto auto 15px 15px; display: flex; flex-direction: column-reverse;">
<button class="update" onclick="load_track(0)">demo.geojson</button>
<button class="update" onclick="load_track(1)">waypoints.geojson</button>
<button class="toggle" onclick="toggle_10()">Switch 10 times</button>
<button class="reset" onclick="load_track(-1)">Clear</button>
</div>

<script>
let opts = {
map: {
mapTypeId: 'satellite',
center: [41.4583, 12.7059],
zoom: 5,
fullscreenControl: false,
minimapControl: false,
gestureHandling: false,
resizerControl: false,
pegmanControl: false,
locateControl: false,
loadingControl: false,
searchControl: false,
preferCanvas: false,
rotate: true,
bearing: 15,
rotateControl: {
closeOnZeroBearing: true
},
},
elevationControl: {
urls: [
"https://raruto.github.io/leaflet-elevation/examples/demo.geojson",
"https://raruto.github.io/leaflet-elevation/examples/waypoints.geojson",
] ,
options: {
position: 'topright',
theme: "lime-theme",
detached: false,
collapsed: false,
autohide: false,
legend: true,
width: 500,
downloadLink: true,
almostOver: true,
distanceMarkers: { distance: false, direction: true, lazy: true },
},
},
layersControl: {
options: {
position: 'bottomleft',
collapsed: false,
},
},
};

let map = L.map('map', opts.map);
let controlElevation = L.control.elevation(opts.elevationControl.options).addTo(map);

controlElevation.load(opts.elevationControl.urls[opts.elevationControl.urls.length - 1]);

let count = 0;

function toggle_10() {
for (let i = 0; i <= 10; i++) {
(function (ind) {
setTimeout(function () {
load_track(count);
}, 1000 * ind);
})(i);
}
}

function load_track(id) {
controlElevation.clear();
if (opts.elevationControl.urls[id]) {
controlElevation.load(opts.elevationControl.urls[id]);
count = ++count % opts.elevationControl.urls.length;
}
}
</script>

<a href="https://github.com/Raruto/leaflet-elevation" class="view-on-github" style="position: fixed;top: 10px;left: calc(50% - 60px);z-index: 9999;"> <img alt="View on Github" src="https://raruto.github.io/img/view-on-github.png" title="View on Github" width="163"> </a>

</body>

</html>
30 changes: 30 additions & 0 deletions examples/leaflet-elevation_clear-button.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* examples/leaflet-elevation_clear-button.html
*/

import * as assert from 'uvu/assert';
import { suite } from '../test/setup/http_server.js';

const test = suite('examples/leaflet-elevation_clear-button.html');

test('eledata_loaded', async ({ page }) => {
let gpx;

gpx = await page.evaluate(() => new Promise(resolve => {
load_track(0);
controlElevation.on('eledata_loaded', (gpx) => resolve(gpx));
}));
assert.is(gpx.name, 'demo.geojson');
assert.not.type(gpx.layer, 'undefined');
assert.type(gpx.track_info.distance, 'number');

gpx = await page.evaluate(() => new Promise(resolve => {
load_track(1);
controlElevation.on('eledata_loaded', (gpx) => resolve(gpx));
}));
assert.is(gpx.name, 'waypoints.geojson');
assert.not.type(gpx.layer, 'undefined');
assert.type(gpx.track_info.distance, 'number');
});

test.run();
5 changes: 3 additions & 2 deletions examples/leaflet-elevation_close-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>

<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.js"></script>

<!-- Blink animation -->
<style>
Expand Down Expand Up @@ -90,6 +90,7 @@
legend: true,
downloadLink: true,
almostOver: true,
edgeScale: false,
distanceMarkers: { distance: false, direction: true, lazy: true }
},
},
Expand Down
4 changes: 2 additions & 2 deletions examples/leaflet-elevation_custom-summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>

<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.js"></script>

<style>
.data-summary {
Expand Down
19 changes: 19 additions & 0 deletions examples/leaflet-elevation_custom-summary.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* examples/leaflet-elevation.html
*/

import * as assert from 'uvu/assert';
import { suite } from '../test/setup/http_server.js';

const test = suite('examples/leaflet-elevation.html');

test('eledata_loaded', async ({ page }) => {
const gpx = await page.evaluate(() => new Promise(resolve => {
controlElevation.on('eledata_loaded', (gpx) => resolve(gpx));
}));
assert.is(gpx.name, 'via-emilia.gpx');
assert.not.type(gpx.layer, 'undefined');
assert.type(gpx.track_info.distance, 'number');
});

test.run();
4 changes: 2 additions & 2 deletions examples/leaflet-elevation_custom-theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>

<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.js"></script>

<!-- Custom theme -->
<style>
Expand Down
4 changes: 2 additions & 2 deletions examples/leaflet-elevation_dynamic-runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>

<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.2.8/dist/leaflet-elevation.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/leaflet-elevation@2.3.0/dist/leaflet-elevation.min.js"></script>

<style>
.runner.height-focus {
Expand Down
Loading