Browse Source

dfds

shibei_master
dai 4 years ago
parent
commit
78e27b469f
  1. 1
      src/assets/scss/main-shuju.scss
  2. 525
      src/router/index.js
  3. 2
      src/views/main-shuju/main.vue
  4. 525
      src/views/modules/visual/warning/index.vue

1
src/assets/scss/main-shuju.scss

@ -346,6 +346,7 @@ body {
} }
&:focus, &:focus,
&:hover { &:hover {
color: #fff;
background-color: transparent !important; background-color: transparent !important;
.navbar__icon-menu { .navbar__icon-menu {

525
src/router/index.js

@ -1,115 +1,116 @@
import Vue from 'vue' import Vue from "vue";
import Router from 'vue-router' import Router from "vue-router";
import http from '@/utils/request' import http from "@/utils/request";
import { import { isURL } from "@/utils/validate";
isURL import store from "@/js/store";
} from '@/utils/validate'
import store from '@/js/store'
Vue.use(Router) Vue.use(Router);
// 页面路由(独立页面) // 页面路由(独立页面)
export const pageRoutes = [{ export const pageRoutes = [
path: '/404', {
component: () => import('@/views/pages/404'), path: "/404",
name: '404', component: () => import("@/views/pages/404"),
name: "404",
meta: { meta: {
title: '404未找到' title: "404未找到",
}, },
beforeEnter(to, from, next) { beforeEnter(to, from, next) {
// 拦截处理特殊业务场景 // 拦截处理特殊业务场景
// 如果, 重定向路由包含__双下划线, 为临时添加路由 // 如果, 重定向路由包含__双下划线, 为临时添加路由
if (/__.*/.test(to.redirectedFrom)) { if (/__.*/.test(to.redirectedFrom)) {
return next(to.redirectedFrom.replace(/__.*/, '')) return next(to.redirectedFrom.replace(/__.*/, ""));
} }
next() next();
} },
}, },
{ {
path: '/login', path: "/login",
component: () => import('@/views/pages/login'), component: () => import("@/views/pages/login"),
name: 'login', name: "login",
meta: { meta: {
title: '登录' title: "登录",
} },
}, },
{ {
path: '/', path: "/",
name: 'index', name: "index",
redirect: { redirect: {
name: 'indexWork' name: "indexWork",
}, },
meta: { meta: {
title: '首页' title: "首页",
} },
}, },
{ {
path: '/indexWork', path: "/indexWork",
component: () => import('@/views/pages/indexWork'), component: () => import("@/views/pages/indexWork"),
name: 'indexWork', name: "indexWork",
meta: { meta: {
title: '工作端首页' title: "工作端首页",
} },
} },
] ];
// 模块路由(基于主入口布局页面) // 模块路由(基于主入口布局页面)
export const moduleRoutes = { export const moduleRoutes = {
path: '/main', path: "/main",
component: () => import('@/views/main'), component: () => import("@/views/main"),
name: 'main', name: "main",
redirect: { redirect: {
name: 'home' name: "home",
}, },
meta: { meta: {
title: '主入口布局' title: "主入口布局",
}, },
children: [{ children: [
path: '/home', {
component: () => import('@/views/modules/home'), path: "/home",
name: 'home', component: () => import("@/views/modules/home"),
name: "home",
meta: { meta: {
title: '主页', title: "主页",
isTab: true isTab: true,
} },
} },
] ],
} };
// 模块路由(基于主入口布局页面) 可视化数据 // 模块路由(基于主入口布局页面) 可视化数据
export const moduleShujuRoutes = { export const moduleShujuRoutes = {
path: '/main-shuju', path: "/main-shuju",
component: () => import('@/views/main-shuju/main'), component: () => import("@/views/main-shuju/main"),
name: 'main-shuju', name: "main-shuju",
redirect: { redirect: {
name: 'home2' name: "home2",
}, },
meta: { meta: {
title: '主入口布局' title: "主入口布局",
}, },
children: [{ children: [
path: '/home2', {
component: () => import('@/views/modules/home'), path: "/home2",
name: 'home2', component: () => import("@/views/modules/home"),
name: "home2",
meta: { meta: {
title: '主页2', title: "主页2",
isTab: true isTab: true,
} },
} },
] ],
} };
export function addDynamicRoute(routeParams, router) { export function addDynamicRoute(routeParams, router) {
// 组装路由名称, 并判断是否已添加, 如是: 则直接跳转 // 组装路由名称, 并判断是否已添加, 如是: 则直接跳转
var routeName = routeParams.routeName var routeName = routeParams.routeName;
var dynamicRoute = window.SITE_CONFIG['dynamicRoutes'].filter( var dynamicRoute = window.SITE_CONFIG["dynamicRoutes"].filter(
(item) => item.name === routeName (item) => item.name === routeName
)[0] )[0];
if (dynamicRoute) { if (dynamicRoute) {
return router.push({ return router.push({
name: routeName, name: routeName,
params: routeParams.params params: routeParams.params,
}) });
} }
// 否则: 添加并全局变量保存, 再跳转 // 否则: 添加并全局变量保存, 再跳转
dynamicRoute = { dynamicRoute = {
@ -117,161 +118,155 @@ export function addDynamicRoute(routeParams, router) {
component: () => import(`@/views/modules/${routeParams.path}`), component: () => import(`@/views/modules/${routeParams.path}`),
name: routeName, name: routeName,
meta: { meta: {
...window.SITE_CONFIG['contentTabDefault'], ...window.SITE_CONFIG["contentTabDefault"],
menuId: routeParams.menuId, menuId: routeParams.menuId,
title: `${routeParams.title}` title: `${routeParams.title}`,
} },
} };
router.addRoutes([{ router.addRoutes([
...moduleRoutes, {
name: `main-dynamic__${dynamicRoute.name}`, ...moduleRoutes,
children: [dynamicRoute] name: `main-dynamic__${dynamicRoute.name}`,
}]) children: [dynamicRoute],
window.SITE_CONFIG['dynamicRoutes'].push(dynamicRoute) },
]);
window.SITE_CONFIG["dynamicRoutes"].push(dynamicRoute);
router.push({ router.push({
name: dynamicRoute.name, name: dynamicRoute.name,
params: routeParams.params params: routeParams.params,
}) });
} }
const router = new Router({ const router = new Router({
mode: 'hash', mode: "hash",
scrollBehavior: () => ({ scrollBehavior: () => ({
y: 0 y: 0,
}), }),
routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes) routes: pageRoutes.concat(moduleRoutes, moduleShujuRoutes),
}) });
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
// 添加动态(菜单)路由 // 添加动态(菜单)路由
// 已添加或者当前路由为页面路由, 可直接访问 // 已添加或者当前路由为页面路由, 可直接访问
if ( if (
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] || window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] ||
fnCurrentRouteIsPageRoute(to, pageRoutes) fnCurrentRouteIsPageRoute(to, pageRoutes)
) { ) {
return next() return next();
} }
const customerId = localStorage.getItem('customerId') const customerId = localStorage.getItem("customerId");
console.log('customerId:', customerId) console.log("customerId:", customerId);
// if(customerId==='1e68188b8f7e9ab15658c164bd5b3676'){ // if(customerId==='1e68188b8f7e9ab15658c164bd5b3676'){
// // if(customerId==='45687aa479955f9d06204d415238f7cc'){ // // if(customerId==='45687aa479955f9d06204d415238f7cc'){
// const menuList=[ // const menuList=[
// { // {
// children: [], // children: [],
// createdBy: "a76fc711807ac9827d7611b0f94ec220", // createdBy: "a76fc711807ac9827d7611b0f94ec220",
// createdTime: "2020-08-26 16:38", // createdTime: "2020-08-26 16:38",
// delFlag: null, // delFlag: null,
// icon: "icon-database", // icon: "icon-database",
// id: "abe812eb350f6b5eda575e268e50ac1c", // id: "abe812eb350f6b5eda575e268e50ac1c",
// name: "定制功能配置", // name: "定制功能配置",
// parentName: null, // parentName: null,
// permissions: "", // permissions: "",
// pid: "0", // pid: "0",
// resourceList: null, // resourceList: null,
// revision: 0, // revision: 0,
// showFlag: 1, // showFlag: 1,
// sort: 2, // sort: 2,
// type: 0, // type: 0,
// updatedBy: "a76fc711807ac9827d7611b0f94ec220", // updatedBy: "a76fc711807ac9827d7611b0f94ec220",
// updatedTime: "2020-09-02 14:49", // updatedTime: "2020-09-02 14:49",
// url: "customer/customize/ConfigItem", // url: "customer/customize/ConfigItem",
// }, // },
// { // {
// children: [], // children: [],
// createdBy: "a76fc711807ac9827d7611b0f94ec220", // createdBy: "a76fc711807ac9827d7611b0f94ec220",
// createdTime: "2020-08-26 16:38", // createdTime: "2020-08-26 16:38",
// delFlag: null, // delFlag: null,
// icon: "icon-file-text", // icon: "icon-file-text",
// id: "8e55eba74c920c00c44c125e3bc73ddc", // id: "8e55eba74c920c00c44c125e3bc73ddc",
// name: "居民端首页配置", // name: "居民端首页配置",
// parentName: null, // parentName: null,
// permissions: "", // permissions: "",
// pid: "0", // pid: "0",
// resourceList: null, // resourceList: null,
// revision: 0, // revision: 0,
// showFlag: 1, // showFlag: 1,
// sort: 3, // sort: 3,
// type: 0, // type: 0,
// updatedBy: "a76fc711807ac9827d7611b0f94ec220", // updatedBy: "a76fc711807ac9827d7611b0f94ec220",
// updatedTime: "2020-09-02 14:49", // updatedTime: "2020-09-02 14:49",
// url: "customer/customize/MiniHome", // url: "customer/customize/MiniHome",
// } // }
// ] // ]
// window.SITE_CONFIG['menuList'] = menuList
// fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
// // next({ ...to, replace: true })
// next({ ...to, replace: true })
// }else{
http
.get('/gov/access/menu/nav')
.then(({
data: res
}) => {
if (res.code !== 0) {
// Vue.prototype.$message.error(res.msg)
return next({
name: 'login'
})
}
window.SITE_CONFIG['menuList'] = res.data
fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
// next({ ...to, replace: true })
next({
...to,
replace: true
})
})
.catch(() => {
next({
name: 'login'
})
})
// }
// localStorage.getItem('customerId') // window.SITE_CONFIG['menuList'] = menuList
// 1e68188b8f7e9ab15658c164bd5b3676 // fnAddDynamicMenuRoutes(window.SITE_CONFIG['menuList'])
// // next({ ...to, replace: true })
// next({ ...to, replace: true })
// }else{
http
.get("/oper/access/menu/nav")
.then(({ data: res }) => {
if (res.code !== 0) {
// Vue.prototype.$message.error(res.msg)
return next({
name: "login",
});
}
window.SITE_CONFIG["menuShujuList"] = [
{
icon: "icon-setting",
id: "2",
name: "基础信息",
url: "visual/basicinfo/basicInfoMain",
},
{
icon: "icon-setting",
id: "3",
name: "人员预警",
url: "visual/warning/index",
},
];
fnAddDynamicMenuRoutes2(window.SITE_CONFIG["menuShujuList"]);
// next({ ...to, replace: true })
next({
...to,
replace: true,
});
})
.catch(() => {
next({
name: "login",
});
});
http http
.get('/oper/access/menu/nav') .get("/gov/access/menu/nav")
.then(({ .then(({ data: res }) => {
data: res if (res.code !== 0) {
}) => { // Vue.prototype.$message.error(res.msg)
if (res.code !== 0) { return next({
// Vue.prototype.$message.error(res.msg) name: "login",
return next({ });
name: 'login' }
}) window.SITE_CONFIG["menuList"] = res.data;
} fnAddDynamicMenuRoutes(window.SITE_CONFIG["menuList"]);
window.SITE_CONFIG['menuShujuList'] = [ // next({ ...to, replace: true })
{ next({
icon: "icon-setting", ...to,
id: "2", replace: true,
name: "基础信息", });
url: "shequ/index" })
}, .catch(() => {
{ next({
icon: "icon-setting", name: "login",
id: "3", });
name: "人员预警", });
url: "base/resi" });
}
]
fnAddDynamicMenuRoutes2(window.SITE_CONFIG['menuShujuList'])
// next({ ...to, replace: true })
next({
...to,
replace: true
})
})
.catch(() => {
next({
name: 'login'
})
})
})
/** /**
* 判断当前路由是否为页面路由 * 判断当前路由是否为页面路由
@ -279,16 +274,16 @@ router.beforeEach((to, from, next) => {
* @param {*} pageRoutes 页面路由 * @param {*} pageRoutes 页面路由
*/ */
function fnCurrentRouteIsPageRoute(route, pageRoutes = []) { function fnCurrentRouteIsPageRoute(route, pageRoutes = []) {
var temp = [] var temp = [];
for (var i = 0; i < pageRoutes.length; i++) { for (var i = 0; i < pageRoutes.length; i++) {
if (route.path === pageRoutes[i].path) { if (route.path === pageRoutes[i].path) {
return true return true;
} }
if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) { if (pageRoutes[i].children && pageRoutes[i].children.length >= 1) {
temp = temp.concat(pageRoutes[i].children) temp = temp.concat(pageRoutes[i].children);
} }
} }
return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false return temp.length >= 1 ? fnCurrentRouteIsPageRoute(route, temp) : false;
} }
/** /**
@ -297,107 +292,109 @@ function fnCurrentRouteIsPageRoute(route, pageRoutes = []) {
* @param {*} routes 递归创建的动态(菜单)路由 * @param {*} routes 递归创建的动态(菜单)路由
*/ */
function fnAddDynamicMenuRoutes(menuList = [], routes = []) { function fnAddDynamicMenuRoutes(menuList = [], routes = []) {
var temp = [] var temp = [];
for (var i = 0; i < menuList.length; i++) { for (var i = 0; i < menuList.length; i++) {
if (menuList[i].children && menuList[i].children.length >= 1) { if (menuList[i].children && menuList[i].children.length >= 1) {
temp = temp.concat(menuList[i].children) temp = temp.concat(menuList[i].children);
continue continue;
} }
// 组装路由 // 组装路由
var route = { var route = {
path: '', path: "",
component: null, component: null,
name: '', name: "",
meta: { meta: {
...window.SITE_CONFIG['contentTabDefault'], ...window.SITE_CONFIG["contentTabDefault"],
menuId: menuList[i].id, menuId: menuList[i].id,
title: menuList[i].name title: menuList[i].name,
} },
} };
// eslint-disable-next-line // eslint-disable-next-line
let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) =>
eval(s2) eval(s2)
) // URL支持{{ window.xxx }}占位符变量 ); // URL支持{{ window.xxx }}占位符变量
if (isURL(URL)) { if (isURL(URL)) {
route['path'] = route['name'] = `i-${menuList[i].id}` route["path"] = route["name"] = `i-${menuList[i].id}`;
route['meta']['iframeURL'] = URL route["meta"]["iframeURL"] = URL;
} else { } else {
URL = URL.replace(/^\//, '').replace(/_/g, '-') URL = URL.replace(/^\//, "").replace(/_/g, "-");
route['path'] = route['name'] = URL.replace(/\//g, '-') route["path"] = route["name"] = URL.replace(/\//g, "-");
route['component'] = () => import(`@/views/modules/${URL}`) route["component"] = () => import(`@/views/modules/${URL}`);
} }
routes.push(route) routes.push(route);
} }
if (temp.length >= 1) { if (temp.length >= 1) {
return fnAddDynamicMenuRoutes(temp, routes) return fnAddDynamicMenuRoutes(temp, routes);
} }
// 添加路由 // 添加路由
router.addRoutes([{ router.addRoutes([
{
...moduleRoutes, ...moduleRoutes,
name: 'main-dynamic-menu', name: "main-dynamic-menu",
children: routes children: routes,
}, },
{ {
path: '*', path: "*",
redirect: { redirect: {
name: '404' name: "404",
} },
} },
]) ]);
window.SITE_CONFIG['dynamicMenuRoutes'] = routes window.SITE_CONFIG["dynamicMenuRoutes"] = routes;
window.SITE_CONFIG['dynamicMenuRoutesHasAdded'] = true window.SITE_CONFIG["dynamicMenuRoutesHasAdded"] = true;
} }
function fnAddDynamicMenuRoutes2(menuList = [], routes = []) { function fnAddDynamicMenuRoutes2(menuList = [], routes = []) {
var temp = [] var temp = [];
for (var i = 0; i < menuList.length; i++) { for (var i = 0; i < menuList.length; i++) {
if (menuList[i].children && menuList[i].children.length >= 1) { if (menuList[i].children && menuList[i].children.length >= 1) {
temp = temp.concat(menuList[i].children) temp = temp.concat(menuList[i].children);
continue continue;
} }
// 组装路由 // 组装路由
var route = { var route = {
path: '', path: "",
component: null, component: null,
name: '', name: "",
meta: { meta: {
...window.SITE_CONFIG['contentTabDefault'], ...window.SITE_CONFIG["contentTabDefault"],
menuId: menuList[i].id, menuId: menuList[i].id,
title: menuList[i].name title: menuList[i].name,
} },
} };
// eslint-disable-next-line // eslint-disable-next-line
let URL = (menuList[i].url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => let URL = (menuList[i].url || "").replace(/{{([^}}]+)?}}/g, (s1, s2) =>
eval(s2) eval(s2)
) // URL支持{{ window.xxx }}占位符变量 ); // URL支持{{ window.xxx }}占位符变量
if (isURL(URL)) { if (isURL(URL)) {
route['path'] = route['name'] = `i-${menuList[i].id}` route["path"] = route["name"] = `i-${menuList[i].id}`;
route['meta']['iframeURL'] = URL route["meta"]["iframeURL"] = URL;
} else { } else {
URL = URL.replace(/^\//, '').replace(/_/g, '-') URL = URL.replace(/^\//, "").replace(/_/g, "-");
route['path'] = route['name'] = URL.replace(/\//g, '-') route["path"] = route["name"] = URL.replace(/\//g, "-");
route['component'] = () => import(`@/views/modules/${URL}`) route["component"] = () => import(`@/views/modules/${URL}`);
} }
routes.push(route) routes.push(route);
} }
if (temp.length >= 1) { if (temp.length >= 1) {
return fnAddDynamicMenuRoutes2(temp, routes) return fnAddDynamicMenuRoutes2(temp, routes);
} }
// 添加路由 // 添加路由
router.addRoutes([{ router.addRoutes([
{
...moduleShujuRoutes, ...moduleShujuRoutes,
name: 'main-dynamic-menu-shuju', name: "main-dynamic-menu-shuju",
children: routes children: routes,
}, },
{ {
path: '*', path: "*",
redirect: { redirect: {
name: '404' name: "404",
} },
} },
]) ]);
window.SITE_CONFIG['dynamicMenuRoutesShuju'] = routes window.SITE_CONFIG["dynamicMenuRoutesShuju"] = routes;
window.SITE_CONFIG['dynamicMenuRoutesShujuHasAdded'] = true window.SITE_CONFIG["dynamicMenuRoutesShujuHasAdded"] = true;
} }
export default router export default router;

2
src/views/main-shuju/main.vue

@ -154,4 +154,4 @@ export default {
} }
</script> </script>
<style lang="scss" src="@/assets/scss/main-shuju.scss"></style> <style lang="scss" src="@/assets/scss/main-shuju.scss" scoped></style>

525
src/views/modules/visual/warning/index.vue

@ -0,0 +1,525 @@
<template>
<div calss="div_main"
style="position: relative">
<!-- 组织路由 -->
<div>
<div class="router_line"></div>
<div class="div_router">
<span class="router_parents"
v-for="(item,index) in runAgency"
:key="index">{{item.name}}<span class="arrow">></span></span>
<span class="router_child">{{orgData.name}}</span>
</div>
</div>
<div class="div_content">
<div id="map"
class="div_map"
:style="{height:mapHeight+'px'}"></div>
<div class="div_data">
<div class="div_search">
<el-input style="width:200px"
v-model="name"
placeholder="请输入姓名"></el-input>
<el-button style="margin-left:10px"
type="primary"
icon="el-icon-plus"
@click="handleSearch">搜索</el-button>
</div>
</div>
</div>
</div>
</template>
<script>
import 'ol/ol.css'
import { Map, View } from 'ol'
import TileLayer from 'ol/layer/Tile.js';
import XYZ from 'ol/source/XYZ.js';
import VectorLayer from 'ol/layer/Vector.js';
import VectorSource from 'ol/source/Vector.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import { defaults as defaultInteractions, Select, DoubleClickZoom } from 'ol/interaction.js';
import { Circle as CircleStyle, Fill, Stroke, Style, Text } from 'ol/style.js';
import { mapGetters } from "vuex";
import { Loading } from 'element-ui'; //Loading
import { requestPost } from "@/js/dai/request";
let loading;//
let x = 1500
let y = 700
let map;
let mapView;
let gaodeMapLayer;//
let polygonLayer;//
let polygonSource;//
let select;//
//
var createTextStyle = function (feature) {
return new Text({
textAlign: undefined,
font: "bold 18px Arial",
//fontFamily: "Courier New, monospace",
fontWeight: "bold",
text: feature.values_.name,
//text: "",
fill: new Fill({ color: "#007ab9" }),
stroke: new Stroke({ color: "#ffffff", width: 3 }),
offsetY: 0,
overflow: true,
});
};
//
var polygonStyleFunction = (function () {
return function (feature) {
return new Style({
fill: new Fill({
color: [255, 255, 255, 0.3]
}),
stroke: new Stroke({
color: [0, 153, 255, 1],
width: 3
}),
text: createTextStyle(feature)
});;
};
})()
const vueGis = {
name: 'HomeMap',
data () {
return {
centerPoint: [],//
zoom: 14,//14
minZoom: 1,//
orgData: {},//
orgId: '',
orgLevel: '',
subAgencyArray: [],//
selPolygonId: '',//id
selPolygon: {},
//
name: "",
//
runNum: 0,
runAgency: [],
}
},
async mounted () {
//
await this.loadOrgData()
//
this.initMap()
//
this.addPolygonLayer()
//
this.loadPolygon(this.subAgencyArray)
},
methods: {
handleSearch () {
},
//
async refreshMap (isRefreshView) {
//
await this.loadOrgData()
//
await this.loadPolygon(this.subAgencyArray)
//
if (isRefreshView) {
this.setMapLocation()
mapView.setCenter(this.centerPoint);
mapView.setZoom(this.zoom);
}
},
//
handleBack () {
this.runNum--
this.runAgency.pop()
if (this.runNum === 0) {
this.orgId = ''
this.orgLevel = ''
} else {
this.orgId = this.runAgency[this.runAgency.length - 1].id
this.orgLevel = this.runAgency[this.runAgency.length - 1].level
}
this.refreshMap(true)
},
//
async loadOrgData () {
const url = "/gov/org/agency/maporg"
// const url = "http://yapi.elinkservice.cn/mock/245/gov/org/agency/maporg"
let params = {
orgId: this.orgId,
level: this.orgLevel
}
const { data, code, msg } = await requestPost(url, params)
if (code === 0) {
this.orgData = data
this.runAgency.push(data)
if (data.children && data.children.length > 0) {
this.subAgencyArray = data.children
}
} else {
this.$message.error(msg)
}
},
//
loadPolygon (subAgencyArray) {
polygonSource.clear()//
let featureData = []//
if (subAgencyArray && subAgencyArray.length > 0) {//
let oneData = {}
subAgencyArray.forEach(agencyItem => {
if (agencyItem.coordinates && agencyItem.coordinates !== '') {//
oneData = {
type: 'Feature',
id: agencyItem.id,
properties: {
id: agencyItem.id,
level: agencyItem.level,
name: agencyItem.name
},
geometry: {
type: 'Polygon',
coordinates: [],
},
}
let coorArray = agencyItem.coordinates.split(',')//
let itemArray = []//[lon,lat]
let polygonArray = []//[[lon,lat],[lon,lat],[lon,lat]]
coorArray.forEach((item, index) => {
itemArray.push(item)
if (index % 2 == 0) {//
} else {//
polygonArray.push(itemArray)
itemArray = []
}
});
oneData.geometry.coordinates.push(polygonArray)
featureData.push(oneData)
}
});
}
if (featureData && featureData.length > 0) {
var geojsonObject = {
'type': 'FeatureCollection',
'features': featureData
};
let feature = (new GeoJSON()).readFeatures(geojsonObject)
polygonSource.addFeatures(feature)
}
},
//
toSubAgency (e) {
console.log(e)
//
this.subAgencyArray.forEach(item => {
if (item.id === e.selected[0].id_) {
this.selPolygonId = item.id
this.selPolygon = item
this.orgId = item.id
this.orgLevel = item.level
}
});
this.runNum++
this.runAgency.push(this.selPolygon)
this.refreshMap(true)
},
//
setMapLocation () {
this.centerPoint = []
if (this.orgData.longitude && this.orgData.latitude) {
this.centerPoint.push(this.orgData.longitude)
this.centerPoint.push(this.orgData.latitude)
}
this.setZoom(this.orgData.agencyLevel)
},
//
setZoom (agencyLevel) {
if (agencyLevel === 'district') {
this.zoom = 14
} else if (agencyLevel === 'street') {
this.zoom = 15
} else if (agencyLevel === 'community') {
this.zoom = 16
}
},
initMap () {
this.setMapLocation()
gaodeMapLayer = new TileLayer({
title: "地图",
source: new XYZ({
//url
url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}',
wrapX: true//xfalse
}),
zIndex: 20
});
mapView = new View({
//
center: this.centerPoint,
// projection: 'EPSG:3857',
projection: 'EPSG:4326',
zoom: this.zoom,
minZoom: this.minZoom
}),
//map
//
map = new Map({
layers: [gaodeMapLayer],
//
view: mapView,
target: 'map'
//map
})
map.on('singleclick', function (e) {
console.log(e.coordinate)
// console.log(transform(e.coordinate, 'EPSG:3857', 'EPSG:4326'));
})
//
const dblClickInteraction = map
.getInteractions()
.getArray()
.find(interaction => {
return interaction instanceof DoubleClickZoom;
});
map.removeInteraction(dblClickInteraction);
},
//
addPolygonLayer () {
polygonSource = new VectorSource({
//features: (new GeoJSON()).readFeatures(geojsonObject)
});
polygonLayer = new VectorLayer({
source: polygonSource,
style: polygonStyleFunction,
zIndex: 50
});
//
var overlayStyle = (function () {
return function (feature) {
var styles = {};
styles['Polygon'] = [
new Style({
stroke: new Stroke({
color: '#ec9000',
width: 2
})
}),
new Style({
fill: new Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
new Style({
text: createTextStyle(feature)
})
];
styles['MultiPolygon'] = styles['Polygon'];
return styles[feature.getGeometry().getType()];
};
})();
select = new Select({
style: overlayStyle
});
map.addLayer(polygonLayer)
map.addInteraction(select);
select.on('select', e => {
this.toSubAgency(e)
});
},
//
startLoading () {
loading = Loading.service({
lock: true, //
text: '正在加载……', //
background: 'rgba(0,0,0,.7)' //
});
},
//
endLoading () {
//clearTimeout(timer);
if (loading) {
loading.close();
}
},
},
props: {
vueFlag: {
type: String,
default: "alarm"
}
},
computed: {
mapHeight () {
return this.clientHeight - 120;
},
// zoom: {
// get () {
// //zoom
// if (this.clientHeight < 900) {
// return 2.3
// } else {
// return 2.8
// }
// },
// set (value) {
// }
// },
...mapGetters(["clientHeight"])
},
components: {},
}
export default vueGis;
</script>
<style lang="scss">
.div_main {
background-color: #12a3ff;
}
.router_line {
width: 106px;
height: 1px;
border: 1px solid #000000;
/* opacity: 0.09; */
}
.div_router {
margin-top: 5px;
.router_parents {
color: #a0c3d9;
font-size: 8px;
.arrow {
padding: 0 5px;
}
}
.router_child {
color: #ffffff;
font-size: 8px;
}
}
.div_search {
text-align: center;
margin-top: 20px;
width: 100%;
display: flex;
justify-content: center;
}
.div_content {
margin-top: 10px;
padding: 10px 10px;
display: flex;
}
.div_map {
width: 100%;
}
.div_data {
flex: 0 0 400px;
margin-left: 20px;
background-color: rgb(233, 235, 235);
border-radius: 5px;
}
</style>
<style>
.ol-overlaycontainer-stopevent {
display: none;
}
</style>
Loading…
Cancel
Save