From 17e7836b1d0a7bd1a51d44ae071a88423a9f9370 Mon Sep 17 00:00:00 2001
From: chenzeping <ChenZeping02609@163.com>
Date: 星期一, 08 三月 2021 17:57:16 +0800
Subject: [PATCH] 添加工具栏功能
---
src/components/panel/ToolBoxPanel.vue | 195 +++++++++++++++++++----
package.json | 4
src/views/MapTemplate.vue | 64 ++++----
src/components/panel/LegendPanel.vue | 6
src/components/plugin/FullScreen.js | 174 +++++++++++++++++++++
src/Sgis.js | 4
6 files changed, 374 insertions(+), 73 deletions(-)
diff --git a/package.json b/package.json
index e098be7..2bd03a4 100644
--- a/package.json
+++ b/package.json
@@ -18,6 +18,7 @@
"dayjs": "^1.9.6",
"echarts": "^4.2.1",
"element-ui": "^2.14.1",
+ "fullscreen": "^1.1.1",
"jquery": "^3.5.1",
"js-cookie": "^2.2.0",
"leaflet": "^1.6.0",
@@ -26,10 +27,11 @@
"lodash": "^4.17.10",
"nprogress": "^0.2.0",
"rbush": "^3.0.1",
- "screenfull": "^3.3.2",
+ "screenfull": "^3.3.3",
"vue": "^2.6.11",
"vue-count-to": "^1.0.13",
"vue-focus": "^2.1.0",
+ "vue-fullscreen": "^2.2.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
diff --git a/src/Sgis.js b/src/Sgis.js
index 22380e4..af7ecb2 100644
--- a/src/Sgis.js
+++ b/src/Sgis.js
@@ -10,6 +10,8 @@
import MapConfig from '@/conf/MapConfig'
import DashFlow from '@components/plugin/PathDashFlow'
import CanvasMarkers from '@components/plugin/CanvasMarkers'
+import FullScreen from '@components/plugin/FullScreen'
+
let map = null
const L = window.L
const initMap = (div) => {
@@ -26,6 +28,8 @@
DashFlow.DashFlow(L) // 娴佸姩绾垮浘
CanvasMarkers.init(L)// 鐢诲竷鍥惧眰
// Leaflet鎵╁睍浠g爜
+ // 鍏ㄥ睆
+ FullScreen.init(L)
map = L.map(div, MapConfig.mapOptions)
diff --git a/src/components/panel/LegendPanel.vue b/src/components/panel/LegendPanel.vue
index 59cce89..70529c2 100644
--- a/src/components/panel/LegendPanel.vue
+++ b/src/components/panel/LegendPanel.vue
@@ -4,7 +4,7 @@
<i class="el-icon-more-outline"></i>
<span>鍥句緥</span>
</div>
- <transition name="fade">
+ <`transition` name="fade">
<div class="legend-content" v-show="legendControl">
<div class="legend-content-box" v-for="(item,index) in legendContents" :key="index">
<p>{{ item.title }}</p>
@@ -258,8 +258,8 @@
}
.fade-leave-active {
- transform-origin: right;
- animation: bounce-in 1s reverse;
+ //transform-origin: right;
+ //animation: bounce-in 1s reverse;
transform-origin: right bottom;
animation: bounce-in .5s reverse;
}
diff --git a/src/components/panel/ToolBoxPanel.vue b/src/components/panel/ToolBoxPanel.vue
index 8f90ff8..5747cc7 100644
--- a/src/components/panel/ToolBoxPanel.vue
+++ b/src/components/panel/ToolBoxPanel.vue
@@ -1,11 +1,25 @@
<template>
<div class="lefttop-toolbox-panel">
- <ul>
- <li v-for="(item,i) in imgList" :key="i" @click="toggleActive(i)" :value="total"
- :class="{'active':activeTools[i]}">
- <img :src="item"/>
- </li>
- </ul>
+ <div class="init-choose" @click="changeSelect()">
+ <img src="@/assets/images/map-pages/icon/toolbox/circle.png" alt="">
+ </div>
+ <!-- <transition name="fade">-->
+ <!-- <ul v-show='selectGroup'>-->
+ <!-- <li v-for="(item,i) in imgList" :key="i" @click="toggleActive(i)" :value="total"><img :src="item"/></li>-->
+ <!-- </ul>-->
+ <!-- </transition>-->
+ <div class="el-select-dropdown" v-show='selectGroup'>
+ <el-dropdown @command="handleCommand" trigger="click" v-for="(item,i) in imgLists" :key="i" :value="total">
+ <transition name="fade">
+ <img :src="item.title" :title="item.alt"/>
+ </transition>
+ <el-dropdown-menu>
+ <el-dropdown-item v-for="(ite,index) in item.items" :key="index" :command='ite.headings'>
+ <span @click='toggleActive(ite)'>{{ ite.headings }}</span>
+ </el-dropdown-item>
+ </el-dropdown-menu>
+ </el-dropdown>
+ </div>
</div>
</template>
@@ -20,35 +34,98 @@
export default {
name: 'ToolBoxPanel',
components: {},
+ props: ['map'],
data () {
return {
isPanelVisible: false,
total: 0,
activeTools: {},
- imgList: {
- circle: circle,
- square: square,
- polygon: polygon,
- legend: legend,
- location: location,
- fullscreen: fullscreen
- },
+ imgLists: [
+ {
+ title: circle,
+ alt: '鏍囩粯',
+ items: [
+ { headings: '绾挎爣缁�' },
+ { headings: '闈㈡爣缁�' },
+ { headings: '绠ご鏍囩粯' }
+ ]
+ },
+ {
+ title: square,
+ alt: '鏍囨敞',
+ items: [
+ { headings: '鐐规爣娉�' },
+ { headings: '绾挎爣娉�' },
+ { headings: '闈㈡爣娉�' },
+ { headings: '鏂囧瓧鏍囨敞' },
+ { headings: '鍥炬爣鏍囨敞' }
+ ]
+ },
+ {
+ title: legend,
+ alt: '娴嬮噺',
+ items: [
+ { headings: '璺濈娴嬮噺' },
+ { headings: '闈㈢Н娴嬮噺' }
+ ]
+ },
+ {
+ title: location,
+ alt: '鍒囨崲搴曞浘',
+ items: [
+ { headings: '褰卞儚鍥�' },
+ { headings: '鐭㈤噺鍥�' },
+ { headings: '鍦板舰鍥�' }
+ ]
+ },
+ {
+ title: polygon,
+ alt: '绠$綉',
+ items: [
+ { headings: '杩為�氭�у垎鏋�' },
+ { headings: '鐖嗙鍒嗘瀽' },
+ { headings: '娴佸悜鍒嗘瀽' },
+ { headings: '妯柇闈㈠垎鏋�' }
+ ]
+ },
+ {
+ title: fullscreen,
+ alt: '涓嬭浇',
+ items: [
+ { headings: '鍏ㄥ睆' },
+ { headings: 'A4妯悜' },
+ { headings: 'A4绾靛悜' }
+ ]
+ }
+ ],
form: {
regionType: '',
enterprise: ''
- }
+ },
+ selectGroup: false,
+ selectGroupOne: false
}
},
methods: {
+ changeSelect () {
+ this.selectGroup = !this.selectGroup
+ },
handleClose (done) {
console.log(done)
},
handleClick (tab, event) {
console.log(tab, event)
},
+ handleCommand (command) {
+ console.log(command)
+ if (command === '鍏ㄥ睆') {
+ this.map.toggleFullscreen()
+ }
+ },
toggleActive (k) {
- this.total++
- this.activeTools[k] = !this.activeTools[k]
+ if (k === 'fullscreen') {
+ this.map.toggleFullscreen()
+ }
},
loadData () {
@@ -58,6 +135,7 @@
this.loadData()
},
created () {
+
}
}
</script>
@@ -67,31 +145,74 @@
position: absolute;
left: 5px;
top: 5px;
- z-index: 1000;
- width: 175px;
- height: 35px;
- line-height: 30px;
- background: #07325b;
- border: 1px solid #5EF2FF;
- border-radius: 3px;
- text-align: center;
+ z-index: 999;
+ display: flex;
- ul {
- list-style: none;
- margin: 0;
- padding: 5px;
+ .init-choose {
+ //margin: 15px 5px;
+ background: #305B62;
+ //margin-top: 15px;
+ width: 35px;
+ height: 35px;
+ border-radius: 50%;
+ border: 2px skyblue solid;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ z-index: 999;
+ }
- li {
- float: left;
- width: 23px;
- height: 23px;
- margin: 0 1px;
- border: 1px solid #073C4F;
+ .el-select-dropdown {
+ position: absolute;
+ z-index: 1;
+ width: 250px;
+ height: 35px;
+ display: flex;
+ align-items: center;
+ justify-content: space-evenly;
+ background: #305B62;
+ border-radius: 15px;
+ padding-inline: 10px;
+ padding-inline-start: 30px;
+
+ .el-dropdow {
+ width: 20%;
+ }
+
+ @keyframes bounce-in {
+ 0% {
+ transform: scale(0);
+ opacity: 0.3;
+ }
+ 100% {
+ transform: scale(1);
+ opacity: 1;
+ }
+ }
+
+ .fade-enter-active {
+ transform-origin: left center;
+ animation: bounce-in .2s;
+ }
+
+ .fade-leave-active {
+ transform-origin: left;
+ animation: bounce-in .2s reverse;
}
}
- .active {
- border: 1px solid #5EF2FF;
+ .el-select-dropdown:last-child {
+ margin-left: 10px;
}
+
+ .el-dropdown-link {
+ cursor: pointer;
+ color: #409EFF;
+ }
+
+ .el-icon-arrow-down {
+ font-size: 12px;
+ }
+
}
</style>
diff --git a/src/components/plugin/FullScreen.js b/src/components/plugin/FullScreen.js
new file mode 100644
index 0000000..888371d
--- /dev/null
+++ b/src/components/plugin/FullScreen.js
@@ -0,0 +1,174 @@
+/* eslint-disable */
+const init = (L) => {
+ (function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ // AMD
+ define(['leaflet'], factory)
+ } else if (typeof module !== 'undefined') {
+ // Node/CommonJS
+ // module.exports = factory(require('leaflet'))
+ factory(L)
+ } else {
+ // Browser globals
+ if (typeof window.L === 'undefined') {
+ throw new Error('Leaflet must be loaded first')
+ }
+ factory(window.L)
+ }
+ }(function (L) {
+ L.Control.Fullscreen = L.Control.extend({
+ options: {
+ position: 'topleft',
+ title: {
+ false: 'View Fullscreen',
+ true: 'Exit Fullscreen'
+ }
+ },
+
+ onAdd: function (map) {
+ var container = L.DomUtil.create('div', 'leaflet-control-fullscreen leaflet-bar leaflet-control')
+
+ this.link = L.DomUtil.create('a', 'leaflet-control-fullscreen-button leaflet-bar-part', container)
+ this.link.href = '#'
+
+ this._map = map
+ this._map.on('fullscreenchange', this._toggleTitle, this)
+ this._toggleTitle()
+
+ L.DomEvent.on(this.link, 'click', this._click, this)
+
+ return container
+ },
+
+ _click: function (e) {
+ L.DomEvent.stopPropagation(e)
+ L.DomEvent.preventDefault(e)
+ this._map.toggleFullscreen(this.options)
+ },
+
+ _toggleTitle: function () {
+ this.link.title = this.options.title[this._map.isFullscreen()]
+ }
+ })
+
+ L.Map.include({
+ isFullscreen: function () {
+ return this._isFullscreen || false
+ },
+
+ toggleFullscreen: function (options) {
+ var container = this.getContainer()
+ if (this.isFullscreen()) {
+ if (options && options.pseudoFullscreen) {
+ this._disablePseudoFullscreen(container)
+ } else if (document.exitFullscreen) {
+ document.exitFullscreen()
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen()
+ } else if (document.webkitCancelFullScreen) {
+ document.webkitCancelFullScreen()
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen()
+ } else {
+ this._disablePseudoFullscreen(container)
+ }
+ } else {
+ if (options && options.pseudoFullscreen) {
+ this._enablePseudoFullscreen(container)
+ } else if (container.requestFullscreen) {
+ container.requestFullscreen()
+ } else if (container.mozRequestFullScreen) {
+ container.mozRequestFullScreen()
+ } else if (container.webkitRequestFullscreen) {
+ container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)
+ } else if (container.msRequestFullscreen) {
+ container.msRequestFullscreen()
+ } else {
+ this._enablePseudoFullscreen(container)
+ }
+ }
+ },
+
+ _enablePseudoFullscreen: function (container) {
+ L.DomUtil.addClass(container, 'leaflet-pseudo-fullscreen')
+ this._setFullscreen(true)
+ this.fire('fullscreenchange')
+ },
+
+ _disablePseudoFullscreen: function (container) {
+ L.DomUtil.removeClass(container, 'leaflet-pseudo-fullscreen')
+ this._setFullscreen(false)
+ this.fire('fullscreenchange')
+ },
+
+ _setFullscreen: function (fullscreen) {
+ this._isFullscreen = fullscreen
+ var container = this.getContainer()
+ if (fullscreen) {
+ L.DomUtil.addClass(container, 'leaflet-fullscreen-on')
+ } else {
+ L.DomUtil.removeClass(container, 'leaflet-fullscreen-on')
+ }
+ this.invalidateSize()
+ },
+
+ _onFullscreenChange: function (e) {
+ var fullscreenElement =
+ document.fullscreenElement ||
+ document.mozFullScreenElement ||
+ document.webkitFullscreenElement ||
+ document.msFullscreenElement
+
+ if (fullscreenElement === this.getContainer() && !this._isFullscreen) {
+ this._setFullscreen(true)
+ this.fire('fullscreenchange')
+ } else if (fullscreenElement !== this.getContainer() && this._isFullscreen) {
+ this._setFullscreen(false)
+ this.fire('fullscreenchange')
+ }
+ }
+ })
+
+ L.Map.mergeOptions({
+ fullscreenControl: false
+ })
+
+ L.Map.addInitHook(function () {
+ if (this.options.fullscreenControl) {
+ this.fullscreenControl = new L.Control.Fullscreen(this.options.fullscreenControl)
+ this.addControl(this.fullscreenControl)
+ }
+
+ var fullscreenchange
+
+ if ('onfullscreenchange' in document) {
+ fullscreenchange = 'fullscreenchange'
+ } else if ('onmozfullscreenchange' in document) {
+ fullscreenchange = 'mozfullscreenchange'
+ } else if ('onwebkitfullscreenchange' in document) {
+ fullscreenchange = 'webkitfullscreenchange'
+ } else if ('onmsfullscreenchange' in document) {
+ fullscreenchange = 'MSFullscreenChange'
+ }
+
+ if (fullscreenchange) {
+ var onFullscreenChange = L.bind(this._onFullscreenChange, this)
+
+ this.whenReady(function () {
+ L.DomEvent.on(document, fullscreenchange, onFullscreenChange)
+ })
+
+ this.on('unload', function () {
+ L.DomEvent.off(document, fullscreenchange, onFullscreenChange)
+ })
+ }
+ })
+
+ L.control.fullscreen = function (options) {
+ return new L.Control.Fullscreen(options)
+ }
+ }))
+}
+export default {
+ init
+}
diff --git a/src/views/MapTemplate.vue b/src/views/MapTemplate.vue
index a1c32db..a98e84c 100644
--- a/src/views/MapTemplate.vue
+++ b/src/views/MapTemplate.vue
@@ -1,19 +1,19 @@
<template>
- <div class="full-screen">
- <popup ref="popup" @callPopup="callPopup"></popup>
- <div id="map" ref="rootmap">
- </div>
- <sgis-layer-controller :preset="'warningPreset'">
- <lc-basemap></lc-basemap>
- <!-- <div class="barline"></div>-->
- <lc-service-layer class="barline" v-if="lcServiceLayerVisible"></lc-service-layer>
- </sgis-layer-controller>
- <monitor-panel></monitor-panel>
-<!-- <top-enterprise-panel></top-enterprise-panel>-->
- <tool-box-panel></tool-box-panel>
- <menu-special></menu-special>
- <legend-panel></legend-panel>
+ <div class="full-screen">
+ <popup ref="popup" @callPopup="callPopup"></popup>
+ <div id="map" ref="rootmap">
</div>
+ <sgis-layer-controller :preset="'warningPreset'">
+ <lc-basemap></lc-basemap>
+ <!-- <div class="barline"></div>-->
+ <lc-service-layer class="barline" v-if="lcServiceLayerVisible"></lc-service-layer>
+ </sgis-layer-controller>
+ <monitor-panel></monitor-panel>
+ <!-- <top-enterprise-panel></top-enterprise-panel>-->
+ <tool-box-panel :map="this.map"></tool-box-panel>
+ <menu-special></menu-special>
+ <legend-panel></legend-panel>
+ </div>
</template>
<script>
@@ -134,23 +134,23 @@
<style lang="less">
- .full-screen {
- width: 100%;
- height: 100%;
- margin: 0;
- padding: 0;
- position: absolute;
+.full-screen {
+ width: 100%;
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ position: absolute;
- #map {
- height: 100%;
- width: 100%;
- }
+ #map {
+ height: 100%;
+ width: 100%;
+ }
- .barline {
- //width: 100%;
- //height: 1px;
- //background-color: #0661AE;
- border-top: 1px solid #0661AE;
- }
- }
-</style>>
+ .barline {
+ //width: 100%;
+ //height: 1px;
+ //background-color: #0661AE;
+ border-top: 1px solid #0661AE;
+ }
+}
+</style>
--
Gitblit v1.8.0