This is a svelte component to add valhalla control for maplibre-gl
npm i @watergis/svelte-maplibre-valhalla
or
yarn add @watergis/svelte-maplibre-valhalla
See Example.
<script lang="ts">
import {
ValhallaIsochronePanel,
ValhallaRoutingPanel,
type ValhallaIsochroneOptions,
type ValhallaRoutingOptions
} from '$lib';
// create maplibre.Map object
let map = new Map();
let valhallaUrl = 'https://valhalla.water-gis.com';
let valhallaIsochroneOptions: ValhallaIsochroneOptions = {
Contours: [
{
time: 3,
distance: 1,
color: 'ff0000'
},
{
time: 5,
distance: 2,
color: 'ffff00'
},
{
time: 10,
distance: 3,
color: '0000ff'
},
{
time: 15,
distance: 4,
color: 'ff00ff'
}
],
isochrone: {
font: ['Roboto Bold'],
fontSize: 16,
fontHalo: 1,
fontColor: '#000000',
fontHaloColor: '#fff'
}
}
let valhallaRoutingOptions: ValhallaRoutingOptions = {
font: ['Roboto Medium'],
fontSize: 14,
fontHalo: 3,
fontColor: '#263238',
fontHaloColor: '#fff',
iconImage: 'marker',
iconSize: 1
};
</script>
<ValhallaIsochronePanel
bind:map={$map}
bind:url={valhallaUrl}
bind:options={valhallaIsochroneOptions}
/>
<ValhallaRoutingPanel
bind:map={$map}
bind:url={valhallaUrl}
bind:options={valhallaRoutingOptions}
/>
Everything you need to build a Svelte project, powered by create-svelte
.
If you're seeing this, you've probably already done this step. Congrats!
# create a new project in the current directory
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest my-app
Once you've created a project and installed dependencies with npm install
(or pnpm install
or yarn
), start a development server:
npm run dev
# or start the server and open the app in a new browser tab
npm run dev -- --open
To create a production version of your app:
npm run build
You can preview the production build with npm run preview
.
To deploy your app, you may need to install an adapter for your target environment.