openlayers集成

This commit is contained in:
王铜 2020-11-17 10:08:52 +08:00
parent abd981f612
commit 0f5fdd6391
5 changed files with 64 additions and 11 deletions

View File

@ -11,6 +11,7 @@
"ant-design-vue": "^1.7.0", "ant-design-vue": "^1.7.0",
"axios": "^0.21.0", "axios": "^0.21.0",
"core-js": "^3.6.5", "core-js": "^3.6.5",
"ol": "^6.4.3",
"vue": "^2.6.11", "vue": "^2.6.11",
"vue-router": "^3.4.8", "vue-router": "^3.4.8",
"vuex": "^3.5.1" "vuex": "^3.5.1"

View File

@ -12,7 +12,7 @@
><icon-font type="wt-iconsearch" />数据查询</span ><icon-font type="wt-iconsearch" />数据查询</span
> >
<a-menu-item-group title="Item 1"> <a-menu-item-group title="Item 1">
<a-menu-item key="setting:1"> Option 1 </a-menu-item> <a-menu-item key="search"> 详细信息 </a-menu-item>
<a-menu-item key="setting:2"> Option 2 </a-menu-item> <a-menu-item key="setting:2"> Option 2 </a-menu-item>
</a-menu-item-group> </a-menu-item-group>
<a-menu-item-group title="Item 2"> <a-menu-item-group title="Item 2">
@ -31,7 +31,7 @@
</a-row> </a-row>
</a-layout-header> </a-layout-header>
<a-layout-content> <a-layout-content>
<component :is="currentComp"/>
</a-layout-content> </a-layout-content>
</a-layout> </a-layout>
</template> </template>
@ -47,14 +47,15 @@ import Admin from '@/components/admin/Index'
export default { export default {
components: { components: {
'icon-font':IconFont, 'icon-font':IconFont,
// 'map':MapLayout, 'map-layout':MapLayout,
// 'search':Search, 'search':Search,
// 'logs':Logs, // 'logs':Logs,
// 'admin':Admin // 'admin':Admin
}, },
data() { data() {
return { return {
current:['map'] current:['map'],
currentComp: 'map-layout'
}; };
}, },
computed: { computed: {
@ -64,7 +65,7 @@ export default {
}, },
methods: { methods: {
handleMenuClick({item, key, keyPath}) { handleMenuClick({item, key, keyPath}) {
this.currentComp = key
} }
} }
}; };

View File

@ -1,13 +1,43 @@
<template> <template>
<div></div> <div>
<div id="map" ref="map" style="height:calc(100vh - 110px);"></div>
</div>
</template> </template>
<script> <script>
export default { import { Map, Tile, View } from "ol";
import OSM from "ol/source/OSM";
import { fromLonLat, toLonLat } from "ol/proj.js";
import TileLayer from "ol/layer/Tile";
import "ol/ol.css";
} export default {
data() {
return {};
},
methods: {
mapinit() {
var map = this.$refs.map;
var layer = new TileLayer({
source: new OSM(),
wrapX: false,
});
new Map({
target: "map",
layers: [layer],
view: new View({
center: fromLonLat([114.3, 30.6]),
zoom: 10,
}),
});
},
},
mounted() {
this.mapinit()
}
};
</script> </script>
<style> <style>
</style> </style>

View File

@ -1,5 +1,10 @@
<template> <template>
<div></div> <div>
<a-layout>
<a-layout-sider>Sider</a-layout-sider>
<a-layout-content>Content</a-layout-content>
</a-layout>
</div>
</template> </template>
<script> <script>

View File

@ -7,6 +7,16 @@ export const instance = axios.create({
baseURL: backendUrl baseURL: backendUrl
}) })
export const URL_MAP = {
DEVICE_LIST: 'device/',
DEVICE_DETAIL: 'device/detail/',
PROJECT_LIST: 'project/',
PROJECT_DETAIL: 'project/detail/',
SENSOR_LIST: 'sensor/',
SENSOR_DETAIL: 'sensor/detail/',
}
export async function login(username, passwd, uuid, capthe) export async function login(username, passwd, uuid, capthe)
{ {
let response = await instance.post('auth', { let response = await instance.post('auth', {
@ -31,4 +41,10 @@ export function setAuth(auth) {
export async function logout() export async function logout()
{ {
instance.defaults.headers['Authorization'] = '' instance.defaults.headers['Authorization'] = ''
}
export async function getData(url, json) {
let response = await instance.get(url, json)
let data = await response.data
return data
} }