Skip to content

Commit

Permalink
expose RawLayer and tweak docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscorn committed Nov 29, 2024
1 parent f74eb6f commit 14fb32c
Show file tree
Hide file tree
Showing 53 changed files with 83 additions and 126 deletions.
25 changes: 19 additions & 6 deletions src/content/CodeBlock.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
<script lang="ts" module>
import type { HighlighterCore } from 'shiki';
import {
createHighlighterCoreSync,
createOnigurumaEngine,
createJavaScriptRegexEngine,
type HighlighterCore
} from 'shiki';
import svelte from 'shiki/langs/svelte.mjs';
import dark from 'shiki/themes/github-dark-default.mjs';
import { browser } from '$app/environment';
const shiki2 = createHighlighterCoreSync({
themes: [dark],
langs: [svelte],
// Use the WASM version of Oniguruma on the browser, and the JS engine on the server
engine: browser ? await createOnigurumaEngine(import('shiki/wasm')) : createJavaScriptRegexEngine()
});
</script>

<script lang="ts">
let {
content,
shiki
content
}: {
content: string;
shiki: HighlighterCore;
} = $props();
const highlighted = $derived.by(() => {
return shiki.codeToHtml(content.trim(), { lang: 'svelte', theme: 'github-dark-default' });
return shiki2.codeToHtml(content.replaceAll('\t', ' ').trim(), { lang: 'svelte', theme: 'github-dark-default' });
});
</script>

Expand All @@ -36,6 +49,6 @@
margin-right: 1.5rem;
display: inline-block;
text-align: right;
color: rgba(115, 138, 148, 0.4);
color: rgba(115, 138, 148, 0.5);
}
</style>
2 changes: 1 addition & 1 deletion src/content/examples/animate-images/AnimateImages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
zoom={5}
center={[-76, 43]}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/animate-images/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Use a series of image sources to create an animation.
import Demo from "./AnimateImages.svelte";
import demoRaw from "./AnimateImages.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/basestyle/BaseStyle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</div>
</div>

<MapLibre class="h-[60vh] min-h-[300px]" style={styleUrl} zoom={4} maxPitch={80} center={{ lng: 137, lat: 36 }}>
<MapLibre class="h-[55vh] min-h-[300px]" style={styleUrl} zoom={4} maxPitch={80} center={{ lng: 137, lat: 36 }}>
<Projection type={globe ? 'globe' : undefined} />
<Light anchor="map" />
<Sky
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/basestyle/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Dynamic contents must be preserved when the base style is changed.
import Demo from "./BaseStyle.svelte";
import demoRaw from "./BaseStyle.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/canvas-source/Canvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<canvas bind:this={canvas} class="hidden" width={SIZE} height={SIZE}>Canvas not supported</canvas>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={2}
center={{ lng: 135, lat: 35 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/canvas-source/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Add a canvas source to the map.
import Demo from "./Canvas.svelte";
import demoRaw from "./Canvas.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/clusters/Clusters.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
zoom={2}
center={{ lng: 180, lat: 35 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/clusters/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Use MapLibre's built-in functions to visualize points as clusters.
import Demo from "./Clusters.svelte";
import demoRaw from "./Clusters.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/complex/Complex.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
</div>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
bind:map
bind:zoom
bind:center
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/complex/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiu
import Demo from "./Complex.svelte";
import demoRaw from "./Complex.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/contour/Contour.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://demotiles.maplibre.org/styles/osm-bright-gl-style/style.json"
zoom={12}
minZoom={10}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/contour/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Render contour lines from a raster DEM source using maplibre-contou
import Demo from "./Contour.svelte";
import demoRaw from "./Contour.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/custom-control/CustomControl.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
});
</script>

<MapLibre class="h-[50vh] min-h-[200px]" style={mapStyle} zoom={12} pitch={40} maxPitch={85} bind:center>
<MapLibre class="h-[55vh] min-h-[200px]" style={mapStyle} zoom={12} pitch={40} maxPitch={85} bind:center>
<!-- inject IControl (useful for plugin) -->
<CustomControl position="top-left" control={myControl} />

Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/custom-control/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Custom Control allows to easily create user defined controls.
import Demo from "./CustomControl.svelte";
import demoRaw from "./CustomControl.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} {shiki} />
<CodeBlock content={demoRaw} />
4 changes: 1 addition & 3 deletions src/content/examples/custom-layer/CustomLayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
const berlin = maplibregl.MercatorCoordinate.fromLngLat({ lng: 13.403, lat: 52.562 });
const kyiv = maplibregl.MercatorCoordinate.fromLngLat({ lng: 30.498, lat: 50.541 });
console.log(helsinki, berlin, kyiv);
// create and initialize a WebGLBuffer to store vertex and color data
this.buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
Expand Down Expand Up @@ -79,7 +77,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={3}
center={[20, 58]}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/custom-layer/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Use a custom style layer to render custom WebGL content.
import Demo from "./CustomLayer.svelte";
import demoRaw from "./CustomLayer.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/custom-protocol/CustomProtocol.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Protocol scheme="myprotocol" loadFn={myProtocolLoadFn} />

<!-- Use custom protocols -->
<MapLibre class="h-[50vh] min-h-[200px]" zoom={6} center={{ lng: 140.0, lat: 37.5 }}>
<MapLibre class="h-[55vh] min-h-[200px]" zoom={6} center={{ lng: 140.0, lat: 37.5 }}>
<VectorTileSource url="pmtiles://https://tile.openstreetmap.jp/static/planet.pmtiles">
<LineLayer sourceLayer="transportation" paint={{ 'line-color': 'orange' }} />
<FillLayer sourceLayer="water" paint={{ 'fill-color': 'dodgerblue' }} />
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/custom-protocol/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: How to add custom protocols.
import Demo from "./CustomProtocol.svelte";
import demoRaw from "./CustomProtocol.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} {shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/deckgl-overlay/DeckGL.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={15}
pitch={60}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/deckgl-overlay/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Interleaving deck.gl with MapLibre layers
import Demo from "./DeckGL.svelte";
import demoRaw from "./DeckGL.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/dynamic-image/DynamicImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={4}
center={{ lng: 137, lat: 36 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/dynamic-image/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Add an icon to the map that was generated at runtime.
import Demo from "./DynamicImage.svelte";
import demoRaw from "./DynamicImage.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/fullscreen/Fullscreen.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px] border-8 border-slate-500"
class="h-[55vh] min-h-[300px] border-8 border-slate-500"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
>
<FullScreenControl position="top-left" />
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/fullscreen/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: View a fullscreen map
import Demo from "./Fullscreen.svelte";
import demoRaw from "./Fullscreen.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/geolocate/Geolocate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
</script>

<div class="flex h-[60vh] min-h-[300px] overflow-hidden rounded-md">
<div class="flex h-[55vh] min-h-[300px] overflow-hidden rounded-md">
<pre class="m-0 flex-1 rounded-none">{logString}</pre>
<MapLibre class="flex-1" style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json">
<GeolocateControl
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/geolocate/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Locate the User
import Demo from "./Geolocate.svelte";
import demoRaw from "./Geolocate.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/hover-styles/HoverStyles.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"
zoom={2}
center={{ lng: -100.486052, lat: 37.830348 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/hover-styles/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Use events and feature states to create a per feature hover effect.
import Demo from "./HoverStyles.svelte";
import demoRaw from "./HoverStyles.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/image-loader/Images.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={1.5}
center={{ lng: -10.0, lat: -20 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/image-loader/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Utility for loading images from URLs
import Demo from "./Images.svelte";
import demoRaw from "./Images.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</script>

<MapLibre
class="relative h-[60vh] min-h-[300px]"
class="relative h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={5}
center={{ lng: 137, lat: 36 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/limit-interaction/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Set the zoom/pitch range and enable or disable UI handlers on the m
import Demo from "./LimitInteraction.svelte";
import demoRaw from "./LimitInteraction.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
2 changes: 1 addition & 1 deletion src/content/examples/plain/Plain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<MapLibre
class="h-[60vh] min-h-[300px]"
class="h-[55vh] min-h-[300px]"
style="https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json"
zoom={3.5}
center={{ lng: 137, lat: 36 }}
Expand Down
3 changes: 1 addition & 2 deletions src/content/examples/plain/content.svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ description: Plain map.
import Demo from "./Plain.svelte";
import demoRaw from "./Plain.svelte?raw";
import CodeBlock from "../../CodeBlock.svelte";
let { shiki } = $props();
</script>

<Demo />

<CodeBlock content={demoRaw} shiki={shiki} />
<CodeBlock content={demoRaw} />
Loading

0 comments on commit 14fb32c

Please sign in to comment.