Skip to content

Commit 3391b60

Browse files
committed
directions about setting up .env
1 parent d11ab33 commit 3391b60

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Add a key here for the 3d buildings page to work
2+
PUBLIC_MAPTILER_KEY=

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@
33
Svelte wrapper for the [maplibre](https://maplibre.org/projects/maplibre-gl-js/) mapping library.
44

55
This library is functional, but I'm still experimenting with extra features to make advanced functionality easier to use. It also needs proper documentation. In the meantime, the [demo site](https://svelte-maplibre.vercel.app) includes code for all the examples, and is a good place to start.
6+
7+
## Developing
8+
9+
You should create a `.env` file to configure the environment. See the `.env.example` file for the
10+
necessary settings.
11+
12+
Currently the only environment variable is a MapTiler API key, required for the 3D Buildings example.
13+
If you don't have one, you can set this to a blank value to use the other examples.

src/routes/examples/3d_buildings/+page.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<script lang="ts">
22
import Map from '$lib/Map.svelte';
3-
import { mapClasses, streetsStyle } from '../styles.js';
3+
import { mapClasses, streetsStyle, hasMaptilerKey } from '../styles.js';
44
import code from './+page.svelte?raw';
55
import CodeSample from '$site/CodeSample.svelte';
66
import FillExtrusionLayer from '$lib/FillExtrusionLayer.svelte';
77
</script>
88

9+
{#if !hasMaptilerKey}
10+
<h2 class="text-red-500">
11+
Please set the PUBLIC_MAPTILER_KEY environment variable to your MapTiler API key to run this
12+
example.
13+
</h2>
14+
{/if}
15+
916
<p>
1017
This example uses a FillExtrusionLayer to show a 3D view of buildings, with shorter buildings in
1118
green and taller buildings in red.<br /> Hold down Ctrl and drag the mouse to rotate on a computer.

src/routes/examples/styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { PUBLIC_MAPTILER_KEY } from '$env/static/public';
22

3+
export const hasMaptilerKey = PUBLIC_MAPTILER_KEY && PUBLIC_MAPTILER_KEY !== 'key';
34
export const streetsStyle = `https://api.maptiler.com/maps/streets-v2/style.json?key=${PUBLIC_MAPTILER_KEY}`;
45

56
export const mapClasses =

0 commit comments

Comments
 (0)