Skip to content

Commit b3f5c2b

Browse files
committed
feat: add all options for leaflet
1 parent ccc039d commit b3f5c2b

19 files changed

+922
-1148
lines changed

README.md

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,92 @@
1-
# Vue 3 + Typescript + Vite
1+
# vue-leaflet
22

3-
This template should help get you started developing with Vue 3 and Typescript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
3+
Here is Vue components for Leaflet maps, which is inspired by [react-leaflet](https://github.com/PaulLeCam/react-leaflet) and [vue-google-maps](https://github.com/GuillaumeLeclerc/vue-google-maps).
44

5-
## Recommended IDE Setup
5+
> A vue component for leaflet.js
66
7-
- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
7+
This branch adapts with vue 3.0, and leaflet 1.9.x.
88

9-
## Type Support For `.vue` Imports in TS
9+
## Completion of components
1010

11-
Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's `.vue` type support plugin by running `Volar: Switch TS Plugin on/off` from VSCode command palette.
11+
- [x] Map
12+
- [x] Marker
13+
- [x] Popup
14+
- [x] Tooltip
15+
- [x] TileLayer
16+
17+
## Installation
18+
19+
```
20+
npm install vueleaflet -save
21+
```
22+
23+
## Startup
24+
25+
You can input some Vue-styled components in a .vue file in order to use leaflet.js, like [Layout.vue](src/Layout.vue).
26+
27+
```
28+
<l-map :zoom="zoom" :center="center" :min-zoom="minZoom" :max-zoom="maxZoom">
29+
<l-tilelayer :url="url" :attribution="attribution"></l-tilelayer>
30+
<l-marker :position="center" :title="title" :opacity="opacity" :draggable="draggable">
31+
<l-tooltip content="a tooltip"></l-tooltip>
32+
</l-marker>
33+
<l-marker :position="marker" :title="title" :opacity="opacity" :draggable="false">
34+
<l-popup content="a popup"></l-popup>
35+
</l-marker>
36+
</l-map>
37+
```
38+
39+
Before that, you should config the vuex, see [main.js](src/main.js)
40+
41+
```
42+
import Vue from 'vue';
43+
import Vuex from 'vuex';
44+
import VueLeaflet from './index'
45+
import App from './Layout';
46+
47+
Vue.use(Vuex);
48+
49+
const store = new Vuex.Store({});
50+
51+
Vue.use(VueLeaflet.plugin,store);
52+
53+
new Vue({
54+
el: '#app',
55+
store,
56+
template: '<App/>',
57+
components: { App },
58+
});
59+
60+
```
61+
62+
## Build Setup
63+
64+
``` bash
65+
# install dependencies
66+
npm install
67+
68+
# serve with hot reload at localhost:8080
69+
npm run dev
70+
71+
# build for production with minification
72+
npm run build
73+
74+
# build for production and view the bundle analyzer report
75+
npm run build --report
76+
77+
# run unit tests
78+
npm run unit
79+
80+
# run all tests
81+
npm test
82+
```
83+
84+
For detailed explanation on how things work, checkout the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
85+
86+
## Contribute
87+
88+
All the developments are on the [develop](https://github.com/brandonxiang/vue-leaflet/tree/next) branch, while the stable version is on the [master](https://github.com/brandonxiang/vue-leaflet/tree/next) branch.
89+
90+
## License
91+
92+
[MIT](LICENSE)
File renamed without changes.

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite App</title>
7+
<title>Vue Leaflet Next</title>
88
</head>
99
<body>
1010
<div id="app"></div>

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "vueleaflet",
3-
"version": "0.0.0",
3+
"version": "3.0.0",
4+
"type": "module",
45
"files": ["dist"],
56
"main": "./dist/vueleaflet.umd.js",
67
"module": "./dist/vueleaflet.es.js",
@@ -16,15 +17,15 @@
1617
"dev": "vite dev"
1718
},
1819
"dependencies": {
19-
"vue": "^3.2.25",
20-
"leaflet": "^1.7.1"
20+
"vue": "^3.3.4",
21+
"leaflet": "^1.9.4"
2122
},
2223
"devDependencies": {
2324
"@types/node": "^17.0.21",
24-
"@types/leaflet": "^1.7.9",
25-
"@vitejs/plugin-vue": "^2.2.0",
25+
"@types/leaflet": "^1.9.4",
26+
"@vitejs/plugin-vue": "^4.3.4",
2627
"typescript": "^4.5.4",
27-
"vite": "^2.8.0",
28-
"vue-tsc": "^0.29.8"
28+
"vite": "^4.4.9",
29+
"vue-tsc": "^1.8.13"
2930
}
3031
}

0 commit comments

Comments
 (0)