forked from viamrobotics/prime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APP-3958] Maplibre component cleanup (viamrobotics#513)
- Loading branch information
1 parent
6cb17f8
commit 72fccc1
Showing
13 changed files
with
230 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!-- | ||
@component | ||
Adds a set of navigation controls. | ||
@example | ||
```html | ||
<MapLibre> | ||
<MapLibreControls /> | ||
</MapLibre> | ||
``` | ||
@see https://maplibre.org/maplibre-gl-js/docs/API/classes/NavigationControl/ | ||
--> | ||
<script lang="ts"> | ||
import { NavigationControl, type ControlPosition } from 'maplibre-gl'; | ||
import { onMount } from 'svelte'; | ||
import { useMapLibre } from './hooks'; | ||
export let position: ControlPosition = 'top-right'; | ||
export let showCompass = true; | ||
export let showZoom = true; | ||
export let visualizePitch = true; | ||
const { map } = useMapLibre(); | ||
const control = new NavigationControl(); | ||
$: control.options.showCompass = showCompass; | ||
$: control.options.showZoom = showZoom; | ||
$: control.options.visualizePitch = visualizePitch; | ||
onMount(() => { | ||
map.addControl(control, position); | ||
return () => { | ||
map.removeControl(control); | ||
}; | ||
}); | ||
</script> |
31 changes: 31 additions & 0 deletions
31
packages/blocks/src/lib/maplibre/directional-marker.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts"> | ||
import Marker from './marker.svelte'; | ||
/** The longitude of the marker. */ | ||
export let lng = 0; | ||
/** The latitude of the marker. */ | ||
export let lat = 0; | ||
/** The rotation angle of the marker (clockwise, in degrees) */ | ||
export let rotation = 0; | ||
/** The relative size of the marker. */ | ||
export let scale = 1; | ||
let element: HTMLElement; | ||
</script> | ||
|
||
<div | ||
bind:this={element} | ||
class="h-7.5 w-7.5" | ||
style:background-image={`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='green' stroke='white' stroke-width='2' %3E%3Cpath d='M12,2L4.5,20.29L5.21,21L12,18L18.79,21L19.5,20.29L12,2Z' /%3E%3C/svg%3E")`} | ||
/> | ||
|
||
<Marker | ||
{element} | ||
{lng} | ||
{lat} | ||
{rotation} | ||
{scale} | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 5 additions & 9 deletions
14
packages/blocks/src/lib/navigation-map/components/robot-marker.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,14 @@ | ||
<script lang="ts"> | ||
import { MapLibreMarker, type GeoPose } from '$lib'; | ||
export let element = document.createElement('div'); | ||
element.style.backgroundImage = `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='green' stroke='white' stroke-width='2' %3E%3Cpath d='M12,2L4.5,20.29L5.21,21L12,18L18.79,21L19.5,20.29L12,2Z' /%3E%3C/svg%3E")`; | ||
element.style.width = `30px`; | ||
element.style.height = `30px`; | ||
import { MapLibreDirectionalMarker, type GeoPose } from '$lib'; | ||
/** The Lng,Lat and rotation of the marker. */ | ||
export let pose: GeoPose | undefined = undefined; | ||
</script> | ||
|
||
{#if pose} | ||
<MapLibreMarker | ||
{element} | ||
{pose} | ||
<MapLibreDirectionalMarker | ||
lng={pose.lng} | ||
lat={pose.lat} | ||
rotation={pose.rotation} | ||
/> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.