-
-
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.
Merge pull request #3 from valiantlynx/valiantlynx-turborepo
Valiantlynx turborepo
- Loading branch information
Showing
53 changed files
with
2,276 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ vite.config.ts.timestamp-* | |
|
||
*.log | ||
.vscode | ||
.dist | ||
.dist | ||
.turbo |
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,58 +1,51 @@ | ||
# create-svelte | ||
# svelte-leaflet | ||
|
||
Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte). | ||
Svelte component for [leaflet](https://leafletjs.com/) | ||
|
||
Read more about creating a library [in the docs](https://kit.svelte.dev/docs/packaging). | ||
[Documentation & Demo](https://ngyewch.github.io/svelte-leaflet/) | ||
|
||
## Creating a project | ||
[Sample project](https://github.com/ngyewch/svelte-leaflet-test) | ||
|
||
If you're seeing this, you've probably already done this step. Congrats! | ||
## Component support | ||
|
||
```bash | ||
# create a new project in the current directory | ||
npm create svelte@latest | ||
- [x] Map | ||
|
||
# create a new project in my-app | ||
npm create svelte@latest my-app | ||
``` | ||
UI layers: | ||
|
||
## Developing | ||
- [x] Marker | ||
- [x] Popup | ||
- [x] Tooltip | ||
|
||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: | ||
Raster layers: | ||
|
||
```bash | ||
npm run dev | ||
- [x] TileLayer | ||
- [x] TileLayer.WMS | ||
- [x] ImageOverlay | ||
- [ ] VideoOverlay | ||
|
||
# or start the server and open the app in a new browser tab | ||
npm run dev -- --open | ||
``` | ||
Vector layers: | ||
|
||
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app. | ||
- [x] Polyline | ||
- [x] Polygon | ||
- [x] Rectangle | ||
- [x] Circle | ||
- [x] CircleMarker | ||
- [ ] SVGOverlay | ||
|
||
## Building | ||
Other layers: | ||
|
||
To build your library: | ||
- [ ] LayerGroup | ||
- [ ] FeatureGroup | ||
- [x] GeoJSON | ||
|
||
```bash | ||
npm run package | ||
``` | ||
Basic types: | ||
|
||
To create a production version of your showcase app: | ||
- [x] Icon | ||
- [x] DivIcon | ||
|
||
```bash | ||
npm run build | ||
``` | ||
Controls: | ||
|
||
You can preview the production build with `npm run preview`. | ||
|
||
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. | ||
## Publishing | ||
|
||
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)). | ||
|
||
To publish your library to [npm](https://www.npmjs.com): | ||
|
||
```bash | ||
npm publish | ||
``` | ||
- [ ] Zoom | ||
- [ ] Attribution | ||
- [ ] Layers | ||
- [x] 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {} | ||
} | ||
}; |
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,3 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; |
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,29 @@ | ||
export default class EventBridge { | ||
constructor(entity, dispatch, events = []) { | ||
this.entity = entity; | ||
|
||
this.eventHandlers = []; | ||
if (events) { | ||
const eventMap = {}; | ||
events.forEach((event) => { | ||
if (!(event in eventMap)) { | ||
const handler = function (e) { | ||
dispatch(event, e); | ||
}; | ||
this.eventHandlers.push({ | ||
event: event, | ||
handler: handler | ||
}); | ||
entity.on(event, handler); | ||
eventMap[event] = handler; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
unregister() { | ||
this.eventHandlers.forEach((entry) => { | ||
this.entity.off(entry.event, entry.handler); | ||
}); | ||
} | ||
} |
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,70 @@ | ||
<script> | ||
import { createEventDispatcher, getContext, onDestroy, setContext } from 'svelte'; | ||
import L from 'leaflet'; | ||
import EventBridge from '$lib/EventBridge'; | ||
const { getMap } = getContext(L); | ||
export let latLng; | ||
export let radius = 10; | ||
export let color = '#3388ff'; | ||
export let weight = 3; | ||
export let opacity = 1.0; | ||
export let lineCap = 'round'; | ||
export let lineJoin = 'round'; | ||
export let dashArray = null; | ||
export let dashOffset = null; | ||
export let fill = true; | ||
export let fillColor = '#3388ff'; | ||
export let fillOpacity = 0.2; | ||
export let fillRule = 'evenodd'; | ||
export let options = {}; | ||
export let events = []; | ||
let circle; | ||
setContext(L.Layer, { | ||
getLayer: () => circle | ||
}); | ||
const dispatch = createEventDispatcher(); | ||
let eventBridge; | ||
$: { | ||
if (!circle) { | ||
circle = L.circle(latLng, options).addTo(getMap()); | ||
eventBridge = new EventBridge(circle, dispatch, events); | ||
} | ||
circle.setLatLng(latLng); | ||
circle.setRadius(radius); | ||
circle.setStyle({ | ||
color: color, | ||
weight: weight, | ||
opacity: opacity, | ||
lineCap: lineCap, | ||
lineJoin: lineJoin, | ||
dashArray: dashArray, | ||
dashOffset: dashOffset, | ||
fill: fill, | ||
fillColor: fillColor, | ||
fillOpacity: fillOpacity, | ||
fillRule: fillRule | ||
}); | ||
} | ||
onDestroy(() => { | ||
eventBridge.unregister(); | ||
circle.removeFrom(getMap()); | ||
}); | ||
export function getCircle() { | ||
return circle; | ||
} | ||
</script> | ||
|
||
<div> | ||
{#if circle} | ||
<slot /> | ||
{/if} | ||
</div> |
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,70 @@ | ||
<script> | ||
import { createEventDispatcher, getContext, onDestroy, setContext } from 'svelte'; | ||
import L from 'leaflet'; | ||
import EventBridge from '$lib/EventBridge'; | ||
const { getMap } = getContext(L); | ||
export let latLng; | ||
export let radius = 10; | ||
export let color = '#3388ff'; | ||
export let weight = 3; | ||
export let opacity = 1.0; | ||
export let lineCap = 'round'; | ||
export let lineJoin = 'round'; | ||
export let dashArray = null; | ||
export let dashOffset = null; | ||
export let fill = true; | ||
export let fillColor = '#3388ff'; | ||
export let fillOpacity = 0.2; | ||
export let fillRule = 'evenodd'; | ||
export let options = {}; | ||
export let events = []; | ||
let circleMarker; | ||
setContext(L.Layer, { | ||
getLayer: () => circleMarker | ||
}); | ||
const dispatch = createEventDispatcher(); | ||
let eventBridge; | ||
$: { | ||
if (!circleMarker) { | ||
circleMarker = L.circleMarker(latLng, options).addTo(getMap()); | ||
eventBridge = new EventBridge(circleMarker, dispatch, events); | ||
} | ||
circleMarker.setLatLng(latLng); | ||
circleMarker.setRadius(radius); | ||
circleMarker.setStyle({ | ||
color: color, | ||
weight: weight, | ||
opacity: opacity, | ||
lineCap: lineCap, | ||
lineJoin: lineJoin, | ||
dashArray: dashArray, | ||
dashOffset: dashOffset, | ||
fill: fill, | ||
fillColor: fillColor, | ||
fillOpacity: fillOpacity, | ||
fillRule: fillRule | ||
}); | ||
} | ||
onDestroy(() => { | ||
eventBridge.unregister(); | ||
circleMarker.removeFrom(getMap()); | ||
}); | ||
export function getCircleMarker() { | ||
return circleMarker; | ||
} | ||
</script> | ||
|
||
<div> | ||
{#if circleMarker} | ||
<slot /> | ||
{/if} | ||
</div> |
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,24 @@ | ||
<script> | ||
import { getContext } from 'svelte'; | ||
import L from 'leaflet'; | ||
const { getMarker } = getContext(L.Marker); | ||
export let options = {}; | ||
let icon; | ||
let html; | ||
$: { | ||
icon = L.divIcon({ ...{ html }, ...options }); | ||
getMarker().setIcon(icon); | ||
} | ||
export function getIcon() { | ||
return icon; | ||
} | ||
</script> | ||
|
||
<div bind:this={html}> | ||
<slot /> | ||
</div> |
Oops, something went wrong.