

230612 서영석 openLayer 기본 지도 추가
@0c4d0994f974bfc4b83698e9fafce0b731ab4583
+++ client/views/component/map/map.vue
... | ... | @@ -0,0 +1,50 @@ |
1 | +<template> | |
2 | + <div ref="map" class="map"></div> | |
3 | + </template> | |
4 | + | |
5 | + <script> | |
6 | + import 'ol/ol.css'; | |
7 | + import { Map, View } from 'ol'; | |
8 | + import { fromLonLat } from 'ol/proj'; | |
9 | + import OSM from 'ol/source/OSM'; | |
10 | + import TileLayer from 'ol/layer/Tile'; | |
11 | + | |
12 | + export default { | |
13 | + data :() =>{ | |
14 | + return { | |
15 | + name: 'Map', | |
16 | + map: null, | |
17 | + } | |
18 | + }, | |
19 | + components: {}, | |
20 | + methods: {}, | |
21 | + watch: {}, | |
22 | + computed: {}, | |
23 | + mounted() { | |
24 | + console.log("started map!!") | |
25 | + this.map = new Map({ | |
26 | + target: this.$refs.map, | |
27 | + view: new View({ | |
28 | + center: fromLonLat([126.9784, 37.5665]), // Centered around Seoul, Korea | |
29 | + zoom: 8, | |
30 | + }), | |
31 | + layers: [ new TileLayer({ | |
32 | + source: new OSM(), | |
33 | + }),], | |
34 | + }); | |
35 | + }, | |
36 | + beforeUnmount() { | |
37 | + this.map.setTarget(null); | |
38 | + }, | |
39 | + }; | |
40 | + | |
41 | + | |
42 | + | |
43 | + </script> | |
44 | + | |
45 | + <style> | |
46 | + .map { | |
47 | + width: 100%; | |
48 | + height: 861px; | |
49 | + } | |
50 | + </style>(파일 끝에 줄바꿈 문자 없음) |
--- client/views/index.ts
+++ client/views/index.ts
... | ... | @@ -10,10 +10,16 @@ |
10 | 10 |
import AppFilters from './pages/AppFilters'; |
11 | 11 |
import App from './pages/App.vue'; |
12 | 12 |
|
13 |
+import OpenLayersMap from "vue3-openlayers"; |
|
14 |
+import "vue3-openlayers/dist/vue3-openlayers.css"; |
|
15 |
+ |
|
13 | 16 |
// const vue = createApp(App).use(AppRouter).mount('#root'); |
14 | 17 |
const vue = createApp(App) |
15 | 18 |
vue.use(AppStore); |
16 | 19 |
vue.use(AppRouter); |
17 | 20 |
vue.config.globalProperties.$filters = AppFilters |
21 |
+ |
|
22 |
+vue.use(OpenLayersMap); |
|
23 |
+ |
|
18 | 24 |
vue.mount('#root'); |
19 | 25 |
|
--- package-lock.json
+++ package-lock.json
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 |
"fs": "0.0.1-security", |
18 | 18 |
"leaflet": "^1.9.4", |
19 | 19 |
"new-line": "^1.1.1", |
20 |
+ "ol": "^7.4.0", |
|
20 | 21 |
"pg": "8.8.0", |
21 | 22 |
"url-loader": "4.1.1", |
22 | 23 |
"vue": "3.2.40", |
--- package.json
+++ package.json
... | ... | @@ -12,6 +12,7 @@ |
12 | 12 |
"fs": "0.0.1-security", |
13 | 13 |
"leaflet": "^1.9.4", |
14 | 14 |
"new-line": "^1.1.1", |
15 |
+ "ol": "^7.4.0", |
|
15 | 16 |
"pg": "8.8.0", |
16 | 17 |
"url-loader": "4.1.1", |
17 | 18 |
"vue": "3.2.40", |
--- webpack.config.js
+++ webpack.config.js
... | ... | @@ -18,6 +18,9 @@ |
18 | 18 |
}, { |
19 | 19 |
test: /\.(js|jsx)?$/, |
20 | 20 |
loader: 'babel-loader', |
21 |
+ options: { |
|
22 |
+ compact: true, |
|
23 |
+ }, |
|
21 | 24 |
}, { |
22 | 25 |
test: /\.css$/, |
23 | 26 |
use: ['vue-style-loader', 'css-loader'] |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?