v-ol-map 1.0.3 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.eslintrc.cjs +29 -0
  2. package/.vscode/extensions.json +3 -0
  3. package/README.md +11 -19
  4. package/dist/ol-map.es.js +8995 -0
  5. package/dist/ol-map.umd.js +2 -0
  6. package/dist/style.css +1 -0
  7. package/dist/vite.svg +1 -0
  8. package/index.html +13 -0
  9. package/package.json +24 -34
  10. package/public/vite.svg +1 -0
  11. package/src/App.vue +13 -0
  12. package/src/assets/vue.svg +1 -0
  13. package/src/components/index.js +13 -0
  14. package/src/components/index.js.map +1 -0
  15. package/src/components/index.ts +16 -0
  16. package/src/components/layers/base.ts +48 -0
  17. package/src/components/layers/tile/index.js +6 -0
  18. package/src/components/layers/tile/index.js.map +1 -0
  19. package/src/components/layers/tile/index.ts +8 -0
  20. package/src/components/layers/tile/tile.vue +97 -0
  21. package/src/components/map/index.js +6 -0
  22. package/src/components/map/index.js.map +1 -0
  23. package/src/components/map/index.ts +8 -0
  24. package/src/components/map/map.vue +91 -0
  25. package/src/main.js +6 -0
  26. package/src/main.js.map +1 -0
  27. package/src/main.ts +6 -0
  28. package/src/style.css +82 -0
  29. package/src/utils/cityMap.js +2260 -0
  30. package/src/utils/cityMap.js.map +1 -0
  31. package/src/utils/cityMap.ts +2263 -0
  32. package/src/utils/index.js +47 -8
  33. package/src/utils/index.js.map +1 -1
  34. package/src/utils/index.ts +68 -17
  35. package/src/vite-env.d.ts +7 -0
  36. package/tsconfig.json +16 -22
  37. package/tsconfig.node.json +9 -0
  38. package/vite.config.ts +40 -0
  39. package/.browserslistrc +0 -3
  40. package/.eslintrc.js +0 -20
  41. package/babel.config.js +0 -3
  42. package/examples/App.vue +0 -26
  43. package/examples/main.ts +0 -13
  44. package/examples/router/index.ts +0 -21
  45. package/examples/views/Home.vue +0 -22
  46. package/lib/demo.html +0 -8
  47. package/lib/v-ol-map.common.js +0 -29682
  48. package/lib/v-ol-map.umd.js +0 -29692
  49. package/lib/v-ol-map.umd.min.js +0 -7
  50. package/public/favicon.ico +0 -0
  51. package/public/index.html +0 -17
  52. package/src/@types/component.d.ts +0 -6
  53. package/src/@types/index.d.ts +0 -3
  54. package/src/@types/shims-tsx.d.ts +0 -13
  55. package/src/@types/shims-vue.d.ts +0 -4
  56. package/src/assets/logo.png +0 -0
  57. package/src/components/Layers/BaseLayer.vue +0 -37
  58. package/src/components/Layers/TileLayer/index.ts +0 -7
  59. package/src/components/Layers/TileLayer/src/index.vue +0 -51
  60. package/src/components/VMap/index.js +0 -6
  61. package/src/components/VMap/index.js.map +0 -1
  62. package/src/components/VMap/index.ts +0 -7
  63. package/src/components/VMap/src/VMap.vue +0 -62
  64. package/src/index.js +0 -21
  65. package/src/index.js.map +0 -1
  66. package/src/index.ts +0 -26
  67. package/vue.config.js +0 -41
@@ -1,19 +1,58 @@
1
- import "ol/ol.css";
2
- import { Map, View } from "ol";
3
- export class VMap {
1
+ // ol
2
+ import 'ol/ol.css';
3
+ import { Map, View } from 'ol';
4
+ import { defaults as defaultControls } from 'ol/control';
5
+ import { defaults as defaultInteractions } from 'ol/interaction';
6
+ // utils
7
+ import { getCenterByCity } from '@/utils/cityMap';
8
+ // functions
9
+ /**
10
+ * 判断某key是否在对象内
11
+ * @param obj
12
+ * @param key
13
+ */
14
+ export const validObjKey = (obj, key) => {
15
+ if (obj && Object.prototype.hasOwnProperty.call(obj, key)) {
16
+ return (obj[key] &&
17
+ (Object.keys(obj[key]).length > 0 || typeof obj[key] === 'function'));
18
+ }
19
+ else {
20
+ return false;
21
+ }
22
+ };
23
+ export class OlMap {
24
+ static map = OlMap;
4
25
  constructor(options) {
5
- this.map = VMap;
26
+ console.log(options);
27
+ // view
6
28
  const viewOptDefault = {
7
29
  center: [108.5525, 34.3227],
8
30
  zoom: 5,
9
31
  constrainResolution: true,
10
- projection: "EPSG:4326",
32
+ projection: 'EPSG:4326'
11
33
  };
12
- const viewOption = { ...viewOptDefault };
34
+ const viewOption = { ...viewOptDefault, ...options.view };
35
+ if (validObjKey(viewOption, 'city') && viewOption.city) {
36
+ viewOption.center =
37
+ getCenterByCity(viewOption.city) ||
38
+ viewOption.center ||
39
+ viewOptDefault.center;
40
+ }
13
41
  const view = new View(viewOption);
14
- new Map({
42
+ // controls
43
+ console.log(options.controls);
44
+ const controlsDefault = {
45
+ zoom: false,
46
+ rotate: false,
47
+ attribution: false
48
+ };
49
+ const controlsOption = { ...controlsDefault, ...options.controls };
50
+ const controls = defaultControls(controlsOption).extend([]);
51
+ return new Map({
52
+ interactions: defaultInteractions(options.interaction).extend([]),
15
53
  target: options.target,
16
- view: view,
54
+ view,
55
+ controls
17
56
  });
18
57
  }
19
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,CAAC;AACnB,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAM/B,MAAM,OAAO,IAAI;IAEf,YAAY,OAAmB;QADzB,QAAG,GAAG,IAAI,CAAC;QAEf,MAAM,cAAc,GAAG;YACrB,MAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC;YAC3B,IAAI,EAAE,CAAC;YACP,mBAAmB,EAAE,IAAI;YACzB,UAAU,EAAE,WAAW;SACxB,CAAC;QACF,MAAM,UAAU,GAAG,EAAE,GAAG,cAAc,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,IAAI,GAAG,CAAC;YACN,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,KAAK;AACL,OAAO,WAAW,CAAA;AAClB,OAAO,EAAE,GAAG,EAAE,IAAI,EA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,cAAc,CAAC,MAAM,CAAA;SAChC;QACD,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;QACjC,WAAW;QACX,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAC7B,MAAM,eAAe,GAAG;YACtB,IAAI,EAAE,KAAK;YACX,MAAM,EAAE,KAAK;YACb,WAAW,EAAE,KAAK;SACnB,CAAA;QACD,MAAM,cAAc,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAA;QAClE,MAAM,QAAQ,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC3D,OAAO,IAAI,GAAG,CAAC;YACb,YAAY,EAAE,mBAAmB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACjE,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI;YACJ,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC"}
@@ -1,26 +1,77 @@
1
- import "ol/ol.css";
2
- import { Map, View } from "ol";
3
-
4
- interface MapOptions {
5
- target: string;
1
+ // ol
2
+ import 'ol/ol.css'
3
+ import { Map, View } from 'ol'
4
+ import { ViewOptions } from 'ol/View'
5
+ import {
6
+ defaults as defaultControls,
7
+ DefaultsOptions as ControlOptions
8
+ } from 'ol/control'
9
+ import {
10
+ defaults as defaultInteractions,
11
+ DefaultsOptions as InteractionOptions
12
+ } from 'ol/interaction'
13
+ // utils
14
+ import { getCenterByCity } from '@/utils/cityMap'
15
+ // interface
16
+ interface customerViewOptions extends ViewOptions {
17
+ city: string;
18
+ }
19
+ export interface MapOptions {
20
+ target: string;
21
+ view: customerViewOptions;
22
+ controls: ControlOptions;
23
+ interaction: InteractionOptions;
24
+ }
25
+ // functions
26
+ /**
27
+ * 判断某key是否在对象内
28
+ * @param obj
29
+ * @param key
30
+ */
31
+ export const validObjKey = (obj: any, key: string) => {
32
+ if (obj && Object.prototype.hasOwnProperty.call(obj, key)) {
33
+ return (
34
+ obj[key] &&
35
+ (Object.keys(obj[key]).length > 0 || typeof obj[key] === 'function')
36
+ )
37
+ } else {
38
+ return false
39
+ }
6
40
  }
7
41
 
8
- export class olMap {
9
- public static map: olMap;
10
- constructor(options: MapOptions) {
11
- console.log(options);
42
+ export class OlMap {
43
+ static map = OlMap
44
+ constructor (options: MapOptions) {
45
+ console.log(options)
46
+ // view
12
47
  const viewOptDefault = {
13
48
  center: [108.5525, 34.3227],
14
49
  zoom: 5,
15
50
  constrainResolution: true,
16
- projection: "EPSG:4326",
17
- };
18
- const viewOption = { ...viewOptDefault };
19
- const view = new View(viewOption);
20
- olMap.map = new Map({
51
+ projection: 'EPSG:4326'
52
+ }
53
+ const viewOption = { ...viewOptDefault, ...options.view }
54
+ if (validObjKey(viewOption, 'city') && viewOption.city) {
55
+ viewOption.center =
56
+ getCenterByCity(viewOption.city) ||
57
+ viewOption.center ||
58
+ viewOptDefault.center
59
+ }
60
+ const view = new View(viewOption)
61
+ // controls
62
+ console.log(options.controls)
63
+ const controlsDefault = {
64
+ zoom: false,
65
+ rotate: false,
66
+ attribution: false
67
+ }
68
+ const controlsOption = { ...controlsDefault, ...options.controls }
69
+ const controls = defaultControls(controlsOption).extend([])
70
+ return new Map({
71
+ interactions: defaultInteractions(options.interaction).extend([]),
21
72
  target: options.target,
22
- view: view,
23
- });
24
- return olMap.map;
73
+ view,
74
+ controls
75
+ })
25
76
  }
26
77
  }
@@ -0,0 +1,7 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue'
5
+ const component: DefineComponent<{}, {}, any>
6
+ export default component
7
+ }
package/tsconfig.json CHANGED
@@ -1,29 +1,23 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "strict": true,
6
- "jsx": "preserve",
7
- "importHelpers": true,
8
- "moduleResolution": "node",
9
- "experimentalDecorators": true,
10
- "esModuleInterop": true,
11
- "allowSyntheticDefaultImports": true,
12
- "sourceMap": true,
13
- "baseUrl": ".",
14
- "typeRoots": ["/@types", "./node_modules/@types"],
15
- "types": ["webpack-env"],
3
+ "baseUrl": "./",
16
4
  "paths": {
17
5
  "@/*": ["src/*"]
18
6
  },
19
- "lib": ["esnext", "dom", "dom.iterable", "scripthost"]
7
+ "target": "ESNext",
8
+ "useDefineForClassFields": true,
9
+ "module": "ESNext",
10
+ "moduleResolution": "Node",
11
+ "strict": true,
12
+ "jsx": "preserve",
13
+ "sourceMap": true,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true,
16
+ "esModuleInterop": true,
17
+ "lib": ["ESNext", "DOM"],
18
+ "skipLibCheck": true
20
19
  },
21
- "include": [
22
- "src/**/*.ts",
23
- "src/**/*.tsx",
24
- "src/**/*.vue",
25
- "tests/**/*.ts",
26
- "tests/**/*.tsx"
27
- ],
28
- "exclude": ["node_modules"]
20
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
21
+ "exclude": ["node_modules"],
22
+ "references": [{ "path": "./tsconfig.node.json" }]
29
23
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true
7
+ },
8
+ "include": ["vite.config.ts"]
9
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,40 @@
1
+ import { resolve } from 'path'
2
+ import { defineConfig } from 'vite'
3
+ // import eslintPlugin from 'vite-plugin-eslint'
4
+ import vue from '@vitejs/plugin-vue'
5
+
6
+ // https://vitejs.dev/config/
7
+ export default defineConfig({
8
+ server: {
9
+ host: 'localhost',
10
+ port: 8080,
11
+ open: true
12
+ },
13
+ plugins: [
14
+ vue()
15
+ // eslintPlugin({
16
+ // include: ['src/**/*.js', 'src/**/*.vue', 'src/**/*.jsx', 'src/**/*.ts'],
17
+ // cache: false
18
+ // })
19
+ ],
20
+ resolve: {
21
+ alias: {
22
+ '@': resolve(__dirname, 'src')
23
+ }
24
+ },
25
+ build: {
26
+ lib: {
27
+ entry: resolve(__dirname, 'src/components/index.ts'),
28
+ name: 'ol-map',
29
+ fileName: (format) => `ol-map.${format}.js`
30
+ },
31
+ rollupOptions: {
32
+ external: ['vue'],
33
+ output: {
34
+ globals: {
35
+ vue: 'Vue'
36
+ }
37
+ }
38
+ }
39
+ }
40
+ })
package/.browserslistrc DELETED
@@ -1,3 +0,0 @@
1
- > 1%
2
- last 2 versions
3
- not dead
package/.eslintrc.js DELETED
@@ -1,20 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: {
4
- node: true,
5
- },
6
- extends: [
7
- "plugin:vue/essential",
8
- "eslint:recommended",
9
- "@vue/typescript/recommended",
10
- "@vue/prettier",
11
- "@vue/prettier/@typescript-eslint",
12
- ],
13
- parserOptions: {
14
- ecmaVersion: 2020,
15
- },
16
- rules: {
17
- "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
18
- "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
19
- },
20
- };
package/babel.config.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- presets: ["@vue/cli-plugin-babel/preset"],
3
- };
package/examples/App.vue DELETED
@@ -1,26 +0,0 @@
1
- <template>
2
- <div id="app">
3
- <router-view />
4
- </div>
5
- </template>
6
-
7
- <style lang="scss">
8
- html,
9
- body {
10
- width: 100%;
11
- height: 100%;
12
- padding: 0;
13
- margin: 0;
14
- }
15
- #app {
16
- font-family: Avenir, Helvetica, Arial, sans-serif;
17
- -webkit-font-smoothing: antialiased;
18
- -moz-osx-font-smoothing: grayscale;
19
- text-align: center;
20
- color: #2c3e50;
21
- width: 100%;
22
- height: 100%;
23
- padding: 0;
24
- margin: 0;
25
- }
26
- </style>
package/examples/main.ts DELETED
@@ -1,13 +0,0 @@
1
- import Vue from "vue";
2
- import App from "./App.vue";
3
- import router from "./router";
4
- import olMap from "@/index";
5
-
6
- Vue.config.productionTip = false;
7
-
8
- Vue.use(olMap);
9
-
10
- new Vue({
11
- router,
12
- render: (h) => h(App),
13
- }).$mount("#app");
@@ -1,21 +0,0 @@
1
- import Vue from "vue";
2
- import VueRouter, { RouteConfig } from "vue-router";
3
- import Home from "../views/Home.vue";
4
-
5
- Vue.use(VueRouter);
6
-
7
- const routes: Array<RouteConfig> = [
8
- {
9
- path: "/",
10
- name: "Home",
11
- component: Home,
12
- },
13
- ];
14
-
15
- const router = new VueRouter({
16
- mode: "history",
17
- base: process.env.BASE_URL,
18
- routes,
19
- });
20
-
21
- export default router;
@@ -1,22 +0,0 @@
1
- <template>
2
- <div class="home">
3
- <v-map :height="height" :width="width">
4
- <v-tile :visible="true"></v-tile>
5
- </v-map>
6
- </div>
7
- </template>
8
-
9
- <script lang="ts">
10
- import { Component, Vue } from "vue-property-decorator";
11
- @Component
12
- export default class Home extends Vue {
13
- height = "960px";
14
- width = "1080px";
15
- }
16
- </script>
17
- <style scoped>
18
- .home {
19
- width: 100%;
20
- height: 100%;
21
- }
22
- </style>
package/lib/demo.html DELETED
@@ -1,8 +0,0 @@
1
- <meta charset="utf-8">
2
- <title>v-ol-map demo</title>
3
- <script src="./v-ol-map.umd.js"></script>
4
-
5
-
6
- <script>
7
- console.log(v-ol-map)
8
- </script>