Skip to content

Commit 34668b5

Browse files
committed
feat: custom plugin
1 parent 22c8afa commit 34668b5

File tree

6 files changed

+2949
-156
lines changed

6 files changed

+2949
-156
lines changed

.release-it.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"git": {
3+
"commitMessage": "chore: release v${version}"
4+
},
5+
"github": {
6+
"release": true
7+
}
8+
}

examples/LCustomPlugin.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script setup lang="ts">
2+
import L from 'leaflet'
3+
import { PropType, inject, nextTick } from 'vue';
4+
import { MAP_PROVIDE, getMapInjectKey, type MapProvide } from '../src';
5+
6+
7+
const mapProvide = inject<MapProvide>(MAP_PROVIDE);
8+
9+
const key = getMapInjectKey();
10+
11+
const props = defineProps({
12+
options: {
13+
type: Object as PropType<L.Control.ZoomOptions>,
14+
required: false
15+
}
16+
})
17+
18+
nextTick(() => {
19+
const zoom = L.control.zoom(props.options);
20+
mapProvide?.getMap(key)?.addControl(zoom);
21+
})
22+
23+
</script>
24+
25+
<template></template>

examples/Layout.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from "../src";
1919
import "../node_modules/leaflet/dist/leaflet.css";
2020
import L from "leaflet";
21-
// import { type GeoJsonObject } from 'geojson';
21+
import LCustomPlugin from './LCustomPlugin.vue';
2222
2323
const mapOptions = {
2424
zoom: 13,
@@ -69,12 +69,14 @@ const tmpGeojson = {
6969
}
7070
};
7171
72+
73+
7274
</script>
7375

7476
<template>
7577
<div>
7678
<h1>Basic UI Layers</h1>
77-
<l-map id="map1" :options="mapOptions">
79+
<l-map id="map1" :options="mapOptions" ref="map1">
7880
<l-tilelayer
7981
urlTemplate="https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
8082
:options="tileLayerOptions"
@@ -189,6 +191,19 @@ const tmpGeojson = {
189191
<LGeojson :geojson="tmpGeojson" />
190192
</l-map>
191193
</div>
194+
<div>
195+
<h1>Custom Plugin</h1>
196+
<l-map
197+
id="map5"
198+
:options="mapOptions"
199+
>
200+
<l-tilelayer
201+
urlTemplate="https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}"
202+
:options="tileLayerOptions"
203+
/>
204+
<LCustomPlugin />
205+
</l-map>
206+
</div>
192207
</template>
193208

194209
<style lang="css">
@@ -200,7 +215,8 @@ const tmpGeojson = {
200215
#map1,
201216
#map2,
202217
#map3,
203-
#map4 {
218+
#map4,
219+
#map5 {
204220
height: 300px;
205221
}
206222

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vueleaflet",
3-
"version": "3.0.2",
3+
"version": "3.0.1",
44
"type": "module",
55
"files": ["dist"],
66
"main": "./dist/vueleaflet.umd.js",
@@ -30,7 +30,8 @@
3030
"@vitejs/plugin-vue": "^4.3.4",
3131
"typescript": "^4.5.4",
3232
"vite": "^4.4.9",
33-
"vue-tsc": "^1.8.13"
33+
"vue-tsc": "^1.8.13",
34+
"release-it": "^16.1.0"
3435
},
3536
"publishConfig": {
3637
"registry": "https://registry.npmjs.org/"

0 commit comments

Comments
 (0)