A small local-first GPX / geoJSON routes viewer
SourceThis lib exposes
Svelte Components:
Lib:
See the demo above for a quick overview.
This can be handy for hikers, bikepackers, travellers, outdoor enthusiasts or if you want to build an app for these users.
Npm install the package
# via npm registry
npm install svelte-local-gpx-viewer
# via github repo (no build artifacts, you'll have to build the lib yourself)
npm install 0gust1/svelte-local-gpx-viewer
All the components:
<script lang="ts">
import { GpxLoad, LocalRoutesList, MapLibreWrapper } from 'svelte-local-gpx-viewer';
</script>
<div>
<div>
<GpxLoad />
</div>
<div>
<LocalRoutesList />
</div>
</div>
<div>
<MapLibreWrapper />
</div>
If you don’t want to use the MapLibreWrapper component, you can use the store exposed by the lib to get the routes and display them on your own map component.
<script lang="ts">
// import the store, it will be populated with the routes
import { liveGeoJSONRoutes } from 'svelte-local-gpx-viewer';
</script>
<!-- Use the store in your app -->
<ul>
{#each ($liveGeoJSONRoutes || []) as route (route.id)}
<li>
<p>{route.name}</p>
<details>
<summary>Route GeoJSON</summary>
<pre>{JSON.stringify(route.data, null, 2)}</pre>
</details>
</li>
{/each}
</ul>
TODO: test case to write and document