明树Git Lab

Commit 6fdf04db authored by zhanghan's avatar zhanghan

可视化大屏开发

parent 0f77ad91
Pipeline #106633 passed with stage
in 17 seconds
<template> <template>
<div id="container" v-loading="mapLoading" element-loading-background="rgba(122, 122, 122, 0)"></div> <div
id="container"
v-loading="mapLoading"
element-loading-background="rgba(122, 122, 122, 0)"
></div>
</template> </template>
<script setup> <script setup>
import AMapLoader from "@amap/amap-jsapi-loader"; import AMapLoader from "@amap/amap-jsapi-loader";
...@@ -11,7 +15,7 @@ import { ...@@ -11,7 +15,7 @@ import {
onUnmounted, onUnmounted,
onActivated, onActivated,
defineEmits, defineEmits,
watch watch,
} from "vue"; } from "vue";
const props = defineProps({ const props = defineProps({
...@@ -24,14 +28,15 @@ watch( ...@@ -24,14 +28,15 @@ watch(
() => props.tabKey, () => props.tabKey,
(newVal) => { (newVal) => {
// 根据页面内容,调整地图显示位置 // 根据页面内容,调整地图显示位置
const center = ["lixiang", "tuichu"].includes(props.tabKey) ? [100.808299, 35.791787] : [127.808299, 35.791787]; const center = ["lixiang", "tuichu"].includes(props.tabKey)
? [100.808299, 35.791787]
: [127.808299, 35.791787];
map && map.setCenter(center); map && map.setCenter(center);
map.setZoom(4); map.setZoom(4);
handleAddMarket(); handleAddMarket();
} }
); );
// 定义事件 // 定义事件
const emit = defineEmits(["province-selected"]); const emit = defineEmits(["province-selected"]);
import gansuLine from "./newLine.json"; import gansuLine from "./newLine.json";
...@@ -52,7 +57,9 @@ const handleInitMap = () => { ...@@ -52,7 +57,9 @@ const handleInitMap = () => {
viewMode: "2D", viewMode: "2D",
zoom: 4, //根据屏幕宽度设置初始化地图级别 zoom: 4, //根据屏幕宽度设置初始化地图级别
zooms: [4, 8], zooms: [4, 8],
center: ["lixiang", "tuichu"].includes(props.tabKey) ? [100.808299, 35.791787] : [127.808299, 35.791787], //初始化地图中心点位置 center: ["lixiang", "tuichu"].includes(props.tabKey)
? [100.808299, 35.791787]
: [127.808299, 35.791787], //初始化地图中心点位置
expandZoomRange: true, // 开启显示范围设置 expandZoomRange: true, // 开启显示范围设置
mapStyle: "amap://styles/d9cd35cfbd75e272e528a7fde0bcfc53", mapStyle: "amap://styles/d9cd35cfbd75e272e528a7fde0bcfc53",
rotateEnable: false, // 是否可以旋转 rotateEnable: false, // 是否可以旋转
...@@ -87,7 +94,7 @@ const handleInitMap = () => { ...@@ -87,7 +94,7 @@ const handleInitMap = () => {
geojsonObj && map.remove(geojsonObj); geojsonObj && map.remove(geojsonObj);
geojsonObj = null; geojsonObj = null;
handleAddMarket(); handleAddMarket();
provincePolylines.forEach(provincePolyline => { provincePolylines.forEach((provincePolyline) => {
map.remove(provincePolyline); map.remove(provincePolyline);
}); });
} }
...@@ -100,8 +107,7 @@ const searchDistrict = () => { ...@@ -100,8 +107,7 @@ const searchDistrict = () => {
key: "9a22433229a51dc5114d4bbf92f687ee", // 申请好的Web端开发者Key key: "9a22433229a51dc5114d4bbf92f687ee", // 申请好的Web端开发者Key
// version: "2.0", // version: "2.0",
plugins: ["AMap.DistrictSearch", "AMap.GeoJSON"], plugins: ["AMap.DistrictSearch", "AMap.GeoJSON"],
}) }).then((AMap) => {
.then((AMap) => {
let districtSearch = new AMap.DistrictSearch({ let districtSearch = new AMap.DistrictSearch({
subdistrict: 1, //获取边界不需要返回下级行政区 subdistrict: 1, //获取边界不需要返回下级行政区
extensions: "all", //返回行政区边界坐标组等具体信息 extensions: "all", //返回行政区边界坐标组等具体信息
...@@ -114,9 +120,9 @@ const searchDistrict = () => { ...@@ -114,9 +120,9 @@ const searchDistrict = () => {
} }
handleInitMap(); handleInitMap();
handleDistrict(); handleDistrict();
}) });
}) });
} };
// 高亮和描边 // 高亮和描边
const handleDistrict = () => { const handleDistrict = () => {
// 描边 // 描边
...@@ -185,7 +191,10 @@ const addPolylines = () => { ...@@ -185,7 +191,10 @@ const addPolylines = () => {
// 鼠标经过 // 鼠标经过
polylineObj.on("mouseover", function (e) { polylineObj.on("mouseover", function (e) {
infoWindow.open(map, [`${e.lnglat.getLng()}`, `${e.lnglat.getLat()}`]); infoWindow.open(map, [
`${e.lnglat.getLng()}`,
`${e.lnglat.getLat()}`,
]);
}); });
// 鼠标移出 // 鼠标移出
polylineObj.on("mouseout", function (e) { polylineObj.on("mouseout", function (e) {
...@@ -284,7 +293,7 @@ const handleAddMarket = () => { ...@@ -284,7 +293,7 @@ const handleAddMarket = () => {
isCustom: true, isCustom: true,
content: infoContent, content: infoContent,
offset: new AMap.Pixel(5, 0), offset: new AMap.Pixel(5, 0),
closeWhenClickMap: true closeWhenClickMap: true,
}); });
const marker = new AMap.Marker({ const marker = new AMap.Marker({
...@@ -296,7 +305,7 @@ const handleAddMarket = () => { ...@@ -296,7 +305,7 @@ const handleAddMarket = () => {
'<img src="//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png" style="width: 40px;height: 40px;">' + '<img src="//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png" style="width: 40px;height: 40px;">' +
`<div class="anchorPoint">${markerData.number}</div>` + `<div class="anchorPoint">${markerData.number}</div>` +
"</div>", "</div>",
zIndex: 100 zIndex: 100,
}); });
// 鼠标悬浮事件 // 鼠标悬浮事件
...@@ -312,7 +321,7 @@ const handleAddMarket = () => { ...@@ -312,7 +321,7 @@ const handleAddMarket = () => {
// 点击事件:聚焦到对应省份并显示省份地图 // 点击事件:聚焦到对应省份并显示省份地图
marker.on("click", function (e) { marker.on("click", function (e) {
// map.remove(provincePolylines); // map.remove(provincePolylines);
provincePolylines.forEach(provincePolyline => { provincePolylines.forEach((provincePolyline) => {
map.remove(provincePolyline); map.remove(provincePolyline);
}); });
provincePolylines = []; provincePolylines = [];
...@@ -486,21 +495,25 @@ onActivated(() => {}); ...@@ -486,21 +495,25 @@ onActivated(() => {});
padding-left: 10px; padding-left: 10px;
padding-top: 5px; padding-top: 5px;
padding-bottom: 5px; padding-bottom: 5px;
p{ p {
height: 51px; height: 51px;
line-height: 51px; line-height: 51px;
display: flex; display: flex;
align-items: center; align-items: center;
&:not(:last-child){ &:not(:last-child) {
position: relative; position: relative;
&::after{ &::after {
content: ""; content: "";
height: 1px; height: 1px;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
right: 0; right: 0;
background: radial-gradient(rgba(255, 255, 255, 0) 0%, #3B71FA 50%, rgba(255, 255, 255, 0) 100%); background: radial-gradient(
rgba(255, 255, 255, 0) 0%,
#3b71fa 50%,
rgba(255, 255, 255, 0) 100%
);
} }
} }
} }
...@@ -595,8 +608,8 @@ onActivated(() => {}); ...@@ -595,8 +608,8 @@ onActivated(() => {});
} }
</style> </style>
<style lang="less"> <style lang="less">
.amap-info{ .amap-info {
z-index: 2; z-index: 2;
pointer-events: none; pointer-events: none;
} }
</style> </style>
\ No newline at end of file
...@@ -211,6 +211,12 @@ const routes = [ ...@@ -211,6 +211,12 @@ const routes = [
title: "投资目标责任书", title: "投资目标责任书",
component: () => import("@/views/everydayPage/shareAdd.vue"), component: () => import("@/views/everydayPage/shareAdd.vue"),
}, },
{
path: "/bigScreen",
name: "bigScreen",
title: "可视化大屏",
component: () => import("@/views/everydayPage/bigScreen.vue"),
},
], ],
}, },
{ {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment