123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785 |
- <template>
- <div id="viewDiv" class="viewDiv">
- <tf-dialog :show.sync="params.tfDialog.Show" :hide.sync="params.tfDialog.Hide" :set-size.sync="params.tfDialog.setSize" />
- <el-container style="height: 100%; width: 100%;">
- <el-container :style="{ height: 'calc(100% - ' + footer_height + ')', width: '100%' }">
- <el-main>
- <div id="antherPanel" style="display: none;width: 50%;height: 100%;float: left;border-right: 3px solid #ccc;" />
-
- <div id="sceneView" ref="sceneView" class="sceneView" v-show="false" :style="{ width: '0'}">
-
- <viewChange />
- <measureMent3D v-if="viewer" :viewer="viewer" />
- <sceneFly v-if="viewer" :viewer="viewer" />
-
- <viewerStatusBar v-if="viewer" :viewer="viewer"></viewerStatusBar>
- </div>
-
- <div id="mapView" ref="mapView" class="mapView" :style="{ marginRight:'0', height: '100%' }">
- <div v-show="labelShow" id="mapLabel">
- <img src="./images/mapLabel.png" />
- </div>
- <div v-show="themShow" id="them" style="position: absolute;left: calc(50% - 250px);top: calc(50% - 150px);">
- <img style="width: 500px; height: 300px;" :src="themSrc" />
- </div>
-
- <div class="tofly-map-query">
- <MapQueryTool v-if="map" :map="map" />
- </div>
-
- <MapZoom v-if="map" :map="map" />
-
- <div class="tofly-tools">
-
-
- <div class="tool-item">
- <LayerControl v-if="map" :map="map" />
- </div>
- <div class="tool-item">
- <MeasureMent v-if="map" :map="map" />
- </div>
- <div class="tool-item">
- <toolBox v-if="map" :map="map" />
- </div>
- </div>
-
- <MapCompass v-if="map" :map="map" />
-
- <viewChange />
-
- <div ref="tofly-map-reset" class="tofly-map-resetMap iconfont icon-fang" title="默认范围" @click="ResetMap" />
-
- <mapLegend />
-
- <div ref="tofly-map-OverviewMap" class="tofly-map-OverviewMap" />
-
- <div class="tofly-map-ScaleLine">
- <span>比例尺:</span>
- <div ref="tofly-map-ScaleLine" />
- </div>
-
- <div ref="tofly-map-MousePosition" class="tofly-map-MousePosition" />
-
- <popupWindow v-if="map" ref="popupWindow" :map="map"></popupWindow>
- </div>
- <float-panels v-if="this.view" :panels="FloatPanels" :data="params" :panel-visible.sync="floatpanel_visible"
- @handelClose="handelClose" />
- <right-half-panals v-if="this.view" :panels="RightHalfPanals" :data="params" :panel-visible.sync="rightpanel_visible"
- @handelClose="handelClose" />
- </el-main>
- <el-aside :style="{ width: side_width, height: '100%' }">
- <side-panels v-if="this.view" :panels="Panels" :data="params" :side-width.sync="side_width"
- :panel-visible.sync="sidepanel_visible" @handelClose="handelClose" />
- </el-aside>
- </el-container>
- <el-footer :style="{ height: footer_height, width: '100%', padding: '0px' }">
- <half-panels v-if="this.view" :panels="HalfPanels" :data="params" :footer-height.sync="footer_height"
- :default-height="halfpanel_defaultHeight" :panel-visible.sync="halfpanel_visible"
- :fullpanel-visible.sync="fullpanel_visible" @handelClose="handelClose" />
- <full-panels v-if="this.view" :panels="FullPanels" :data="params" :footer-height.sync="footer_height"
- :panel-visible.sync="fullpanel_visible" :halfpanel-visible.sync="halfpanel_visible" @handelClose="handelClose" />
- </el-footer>
- </el-container>
- </div>
- </template>
- <script>
- import Layout from '@/layout';
- import 'ol/ol.css';
- import Comps from '@/layout/components/loadComps';
- import { HalfPanels, FullPanels, FloatPanels, SidePanels, RightHalfPanals } from '@/layout/components/index';
- import { esriConfig } from 'staticPub/config';
- import { loadCss } from '@/utils/loadResources';
- import tfDialog from './common/Dialog';
- import { Map, View, Feature, Overlay } from 'ol';
- import { Polygon, Point, LineString, MultiLineString } from 'ol/geom';
- import { Image as ImageLayer, Vector as VectorLayer, Tile as TileLayer } from 'ol/layer';
- import { OSM, XYZ, ImageWMS, Vector as VectorSource } from 'ol/source';
- import { Style, Fill, Stroke, Icon, Text, Circle } from 'ol/style';
- import { createStringXY } from 'ol/coordinate';
- import { unByKey } from 'ol/Observable';
- import { OverviewMap, ScaleLine, defaults, MousePosition, FullScreen, Zoom } from 'ol/control';
- import MapQueryTool from './mapViewTools/mapQuery';
- import { Select, Draw } from 'ol/interaction';
- import { altKeyOnly, click, pointerMove } from 'ol/events/condition';
- import { mapConfig } from './map.config';
- import { getSiteInfoList, getAlarmEventList } from '@/api/oneMap';
- import { format } from 'ol/coordinate';
- import { bbox as bboxStrategy } from 'ol/loadingstrategy';
- import GeoJSON from 'ol/format/GeoJSON';
- import { getVectorContext } from 'ol/render';
- import * as turf from '@turf/turf'
- import { Logo, TileSuperMapRest, SuperMap, FeatureService } from '@supermap/iclient-ol';
- import { Projection, addProjection, get as getProjection, fromLonLat, transform } from 'ol/proj';
- import { register as olRegisterProj } from 'ol/proj/proj4';
- import proj4 from 'proj4'
- import MapZoom from '@/views/MapView/mapViewTools/mapZoom';
- import MeasureMent from './mapViewTools/measureMent';
- import FeatureEdit from './mapViewTools/featureEditTools';
- import LayerControl from '@/views/MapView/mapViewTools/layerControl';
- import viewToggle from '@/views/MapView/mapViewTools/viewToggle';
- import screenShots from '@/views/MapView/mapViewTools/screenShots';
- import MapToggle from '@/views/MapView/mapViewTools/basicMapToggle';
- import toolBox from '@/views/MapView/mapViewTools/toolBox';
- import viewChange from '@/views/MapView/mapViewTools/viewChange';
- import measureMent3D from '@/views/MapView/mapViewTools/measureMent3D';
- import sceneFly from '@/views/MapView/mapViewTools/sceneFly';
- import MapCompass from '@/views/MapView/mapViewTools/mapCompass';
- import viewerStatusBar from '@/views/MapView/mapViewTools/viewerStatusBar'
- import popupWindow from '@/views/MapView/mapViewTools/popupWindow'
- import mapLegend from '@/views/MapView/mapViewTools/mapLegend'
- import { getFields } from '@/api/kxc/pipelineSystem'
- import { async } from 'q';
- const Cesium = window.Cesium;
- export default {
- components: {
- HalfPanels,
- FullPanels,
- FloatPanels,
- SidePanels,
- RightHalfPanals,
- tfDialog,
- MapQueryTool,
- MapZoom,
- MeasureMent,
- LayerControl,
- viewToggle,
- screenShots,
- MapToggle,
- toolBox,
- viewChange,
- measureMent3D,
- FeatureEdit,
- MapCompass,
- sceneFly,
- viewerStatusBar,
- popupWindow,
- mapLegend
- },
- data() {
- return {
- config: null,
- projection: null,
- map: null,
- layers: [],
- monitorLayer: null,
- viewTileLayers: [],
- controls: null,
- view: null,
- Comps,
- show: true,
- themShow: false,
- themSrc: '',
- labelShow: false,
- side_width: '0%',
- footer_height: '0%',
- sidepanel_visible: false,
- floatpanel_visible: false,
- rightpanel_visible: false,
- halfpanel_visible: false,
- fullpanel_visible: false,
- halfpanel_defaultHeight: '400px',
- params: {
- mapView: this.view,
- that: this,
-
- activeModel: null,
- tfDialog: {
- Show: null,
- Hide: null,
- setSize: null
- }
- },
-
- legend: false,
- inputInfo: '',
- sceneView_visible: true,
- viewer: null,
- viewChangeStep: 2,
-
-
- queryByClick: {
- querying: false,
- resultInfo: null
- },
- popupInfo: null
- };
- },
- computed: {
- Panels() {
- return this.$store.state.map.panels;
- },
- FullPanels() {
- return this.$store.state.map.fullPanels;
- },
- HalfPanels() {
- return this.$store.state.map.halfPanels;
- },
- FloatPanels() {
- return this.$store.state.map.floatPanels;
- },
- RightHalfPanals() {
- return this.$store.state.map.rightHalfPanels;
- },
- },
- watch: {
- FullPanels() {
- this.show = true;
- }
- },
- created: function () {
- },
- mounted: function () {
- loadCss(esriConfig.baseCssUrl);
- const _this = this;
- this.$nextTick(function () {
- _this.getProj()
- _this.initMap();
- _this.addIserverLayers()
- _this.creatSceneView()
- });
- this.config = mapConfig;
- this.getPipeFields()
-
- this.$erd.listenTo(this.$refs.mapView, element => {
- this.map.updateSize();
- });
- },
- methods: {
- handelClose() {
- this.show = false;
- },
- getProj() {
- proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs");
- olRegisterProj(proj4);
- this.projection = new Projection({
- code: "EPSG:4490",
- extent: [-180, -90, 180, 90],
- worldExtent: [-180, -90, 180, 90],
- units: "degrees"
- });
- addProjection(this.projection);
- },
- initMap() {
- this.getMap(this.config);
- this.getMapTools(this.config);
- this.map = new Map({
- target: 'mapView',
- layers: this.layers,
- view: this.view,
- controls: this.controls
- });
-
-
-
-
-
-
- $('.ol-overviewmap button').addClass('iconfont iconyy');
-
-
-
-
-
-
- this.map.on('moveend', evt => {
- console.log("地图级别", this.map.getView().getZoom())
- this.map_extentChangeHandler()
- })
-
- this.map.on("click", async event => {
- let pipelineDataServer = mapConfig.iServerUrl.pipelineDataServer
- await this.clickQuery(event.coordinate, pipelineDataServer)
- })
- },
- addIserverLayers() {
-
- this.loadiServerLayers(this.config.iServerUrl.baseMapLayers)
-
- this.loadiServerLayers(this.config.iServerUrl.publicHouseLayers)
-
- this.loadiServerLayers(this.config.iServerUrl.basicGISLayers)
-
- this.loadiServerLayers(this.config.iServerUrl.pipelineLayers)
- },
-
- getMap(options) {
- if (!options) return;
-
- let viewTileLayer = options.iServerUrl.baseMapLayers.filter(item => {
- return item.name == '电子地图'
- });
- if (viewTileLayer.length > 0) {
- this.viewTileLayers = [
- new TileLayer({
- source: new TileSuperMapRest({
- url: viewTileLayer[0].url,
- crossOrigin: 'anonymous'
- })
- })
- ]
- }
- this.view = new View({
- center: [104.753586, 31.521350],
-
- projection: "EPSG:4326",
- zoom: 15,
- maxZoom: 23,
- minZoom: 13,
- constrainResolution: true
- });
- this.params.mapView = this.view;
- },
-
- getMapTools(options) {
- const arrControls = [];
-
- arrControls.push(
- new ScaleLine({
- units: 'metric',
- target: this.$refs['tofly-map-ScaleLine']
- })
- );
-
- arrControls.push(
- new MousePosition({
- coordinateFormat: coordinate => {
- return format(coordinate, '经度:{x} 纬度:{y}', 6);
- },
- target: this.$refs['tofly-map-MousePosition']
- })
- );
-
- arrControls.push(
- new OverviewMap({
- target: this.$refs['tofly-map-OverviewMap'],
- layers: this.viewTileLayers,
- collapseLabel: '',
- label: '',
- collapsed: false,
- tipLabel: '鹰眼'
- })
- );
- if (arrControls && arrControls.length > 0) {
- this.controls = defaults({
- attribution: false,
- zoom: false,
- rotate: false
- }).extend(arrControls);
- }
- },
-
- ResetMap() {
-
- this.view.setZoom(15);
- this.view.animate({
- center: [104.753586, 31.521350],
- duration: 600
- });
- },
-
- loadiServerLayers(LAYERS) {
- LAYERS.forEach(item => {
- this.map.addLayer(new TileLayer({
- source: new TileSuperMapRest({
- url: item.url,
- wrapX: true,
- crossOrigin: 'anonymous'
- }),
- name: item.name,
- type: item.type,
- visible: item.visible
- }))
- })
- },
-
- creatSceneView() {
- this.viewer = new Cesium.Viewer("sceneView", {
- imageryProvider: new Cesium.WebMapTileServiceImageryProvider({
- url: 'http://t0.tianditu.gov.cn/img\_w/wmts?tk=700ea8c1e2dd873c349dc880169fd96d',
- layer: 'img',
- style: 'default',
- tileMatrixSetID: 'w',
- format: 'tiles',
- maximumLevel: 18
- }),
- infoBox: false
- });
-
- this.viewer.scene.camera.moveEnd.addEventListener(() => {
-
-
-
- this.viewChangeStep--
- if (this.viewChangeStep === 1) {
- const cameraExtent = this.viewer.camera.computeViewRectangle()
- let viewExtent = [
- cameraExtent.west * (180 / Math.PI),
- cameraExtent.south * (180 / Math.PI),
- cameraExtent.east * (180 / Math.PI),
- cameraExtent.north * (180 / Math.PI)
- ]
- this.map.getView().fit(viewExtent, this.map.getSize(), { duration: 1000 })
- }
- else
- this.viewChangeStep = 2
- })
-
- let s3mArray = this.config.iServerUrl.sceneService
- s3mArray.forEach(item => {
- this.viewer.scene.addS3MTilesLayerByScp(item.url, { name: item.name })
- });
- this.config.iServerUrl.tiles3D.forEach(item => {
- this.viewer.scene.open(item)
- })
- },
-
- map_extentChangeHandler() {
- this.viewChangeStep--;
- if (this.viewChangeStep === 1) {
- let viewExtent = this.map.getView().calculateExtent(this.map.getSize())
- this.viewer.camera.setView({
- destination: Cesium.Rectangle.fromDegrees(viewExtent[0], viewExtent[1], viewExtent[2], viewExtent[3]),
- })
- } else {
- this.viewChangeStep = 2
- }
- },
-
- async clickQuery(position, DataServer) {
- this.queryByClick.querying = true
- console.log('地图点击查询开始')
- document.getElementById('mapView').style = "cursor:wait"
- let zoom = this.map.getView().getZoom()
-
- if (zoom <= 15) {
- document.getElementById('mapView').style = "cursor:default"
- this.popupWindowClose()
- setTimeout(() => {
- this.queryByClick.querying = false
- console.log('小比例尺,地图点击查询结束')
- }, 500);
- return false;
- }
- let dis = 60 / 100000
- if (zoom > 15) dis = 25 / 10000
- if (zoom >= 17) dis = 12 / 10000
- if (zoom >= 20) dis = 5 / 10000
- if (zoom >= 23) dis = 3 / 10000
- let bufferPoint = turf.buffer(turf.point(position), dis, { units: 'kilometers' })
- console.log("级别:", zoom, "缓冲:", dis * 1000)
- let resultArray = []
- for (let i = 0; i < DataServer.dataSetInfo.length; i++) {
-
- let geometryParam = new SuperMap.GetFeaturesByGeometryParameters({
- toIndex: -1,
- maxFeatures: 10,
- datasetNames: [DataServer.dataSource + ':' + DataServer.dataSetInfo[i].name],
- geometry: new GeoJSON().readFeature(bufferPoint).getGeometry(),
- spatialQueryMode: "INTERSECT"
- })
- await this.doClickQuery(DataServer.url, geometryParam).then(res => {
- if (res && res.result.features.features.length > 0) {
- let feature = res.result.features.features[0]
- feature["dataType"] = DataServer.dataSetInfo[i]
- if (feature.dataType.type == "line")
- resultArray.push(feature)
- else if (feature.dataType.type == "point")
- resultArray.unshift(feature)
- }
- })
- }
- if (resultArray.length > 0) {
-
- this.popupWindowShow(position, resultArray[0])
- }
- else this.popupWindowClose()
- document.getElementById('mapView').style = "cursor:default"
- this.queryByClick.querying = false
- console.log('地图点击查询结束!!')
- },
-
- doClickQuery(url, geometryParam) {
- return new Promise((resolve) => {
-
- new FeatureService(url).getFeaturesByGeometry(geometryParam, serviceResult => {
- if (serviceResult.type == "processFailed") {
- resolve(null);
- }
- else {
- resolve(serviceResult);
- }
- })
- });
- },
-
- popupWindowShow(position, feature) {
- this.$refs.popupWindow.showPopup(position, feature)
- this.queryByClick.resultInfo = { coordinate: position, feature: feature }
- this.popupInfo = { coordinate: position, feature: feature }
- },
-
- popupWindowClose() {
- this.$refs.popupWindow.closePopup()
- this.queryByClick.resultInfo = null
- this.popupInfo = null
- },
-
- getPipeFields() {
- getFields(1).then(res => { this.$store.dispatch('common/setPipeLineFields', res.result) })
- getFields(2).then(res => { this.$store.dispatch('common/setPipePointFields', res.result) })
- getFields(3).then(res => { this.$store.dispatch('common/setGroundFields', res.result) })
- getFields(4).then(res => { this.$store.dispatch('common/setBuildingFields', res.result) })
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .viewDiv {
- position: absolute;
- margin: 0px auto;
- width: calc(100% - 0px);
- height: calc(100% - 40px);
- .el-main {
- padding: 0px;
- overflow: hidden;
- *zoom: 1;
- }
- .sceneView {
- position: relative;
- float: right;
- height: 100%;
- background-color: #fffff2;
- }
- .mapView {
- position: relative;
- background-color: #fffff2;
- height: 100%;
- .tofly-Tool-mapControl {
- position: absolute;
- width: 350px;
- height: 400px;
- z-index: 333;
- background-color: rgba(255, 255, 255, 0.9);
- right: 12px;
- top: 52px;
- border-radius: 4px;
- border: 1px solid #e2e2e2;
- }
- .tofly-map-query {
- position: absolute;
- width: auto;
- height: 40px;
- z-index: 3;
- top: 10px;
- left: 15px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
- // opacity: 0.9;
- }
- .tofly-map-ScaleLine {
- position: absolute;
- width: 300px;
- color: #000;
- height: 35px;
- z-index: 333;
- bottom: 0;
- left: 80px;
- > span {
- height: 35px;
- line-height: 35px;
- }
- >>> .ol-scale-line {
- background: transparent;
- margin-left: 60px;
- height: 100%;
- bottom: 0;
- .ol-scale-line-inner {
- border-width: 2px;
- border-color: #000;
- color: #000;
- margin-top: 8px;
- }
- }
- }
- .tofly-map-resetMap {
- position: absolute;
- background-color: rgb(255, 255, 255);
- border-radius: 2px;
- color: #444444;
- width: 32px;
- height: 32px;
- line-height: 32px;
- font-weight: 600;
- text-align: center;
- right: 15px;
- z-index: 333;
- bottom: 178px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
- cursor: pointer;
- &:hover {
- color: #006eb8;
- }
- }
- .tofly-tools {
- position: absolute;
- top: 10px;
- right: 15px;
- width: auto;
- padding: 0 10px;
- height: 40px;
- line-height: 40px;
- background-color: rgb(255, 255, 255);
- z-index: 333;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
- // border-radius: 4px;
- .tool-item {
- display: inline-block;
- vertical-align: middle;
- padding: 0 10px;
- cursor: pointer;
- // background-color: rgba(255, 255, 255, 0.9);
- }
- }
- .tofly-map-MousePosition {
- position: absolute;
- width: 400px;
- height: 35px;
- z-index: 333;
- bottom: 0;
- // right: 460px;
- left: 200px;
- color: #000;
- // font-weight: 600;
- }
- .tofly-map-OverviewMap {
- position: absolute;
- z-index: 333;
- width: 32px;
- height: 32px;
- bottom: 35px;
- right: 15px;
- background-color: #fff;
- cursor: pointer;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
- >>> .ol-overviewmap {
- background-color: #fff !important;
- left: unset !important;
- right: 40px !important;
- bottom: 0.1px !important;
- border-radius: 2px;
- button {
- cursor: pointer;
- &:hover {
- color: #006eb8;
- }
- }
- }
- >>> .ol-overviewmap .ol-overviewmap-map {
- height: 200px;
- width: 300px;
- }
- >>> .ol-overviewmap button {
- // display: none;
- background-color: #fff;
- color: #444444;
- border-radius: 2px;
- outline: none;
- }
- >>> .ol-overviewmap button {
- left: unset !important;
- bottom: 4px;
- right: -36px;
- position: absolute;
- }
- }
- .bottom-contant {
- position: absolute;
- bottom: 0;
- width: 100%;
- height: 40px;
- background-color: rgba(27, 27, 27, 0.7);
- z-index: 333;
- }
- #mapLabel {
- position: absolute;
- z-index: 333;
- bottom: 0;
- }
- }
- .ol-overlay-container {
- span {
- display: block;
- width: 20px;
- height: 42px;
- border-radius: 50%;
- background: url('/images/rhkSelect.gif') no-repeat;
- background-size: 20px 42px;
- border: 1px red solid;
- }
- }
- }
- .tofly-overviewmap {
- right: 100px;
- }
- .close {
- position: absolute;
- right: 0;
- cursor: pointer;
- }
- </style>
|