| | |
| | | Rotate, |
| | | } from "ol/control.js"; |
| | | |
| | | import VectorLayer from "ol/layer/Vector"; |
| | | import VectorSource from "ol/source/Vector"; |
| | | |
| | | import { OSM, TileWMS, Vector } from "ol/source"; |
| | | // import Draw from "ol/interaction/Draw"; |
| | | import Draw from "./Draw"; |
| | | |
| | | import Feature from "ol/Feature.js"; |
| | | import Point from "ol/geom/Point.js"; |
| | | import LineString from "ol/geom/LineString.js"; |
| | | import { Icon, Style, Fill, Stroke } from "ol/style.js"; |
| | | |
| | | // import drawFence from "./drawFence"; |
| | | |
| | | import OlFeature from "ol/Feature"; |
| | | import OlGeomPoint from "ol/geom/Point"; |
| | | // import OlLayerVector from "ol/layer/Vector"; |
| | | // import OlSourceVector from "ol/source/Vector"; |
| | | import OlStyleStyle from "ol/style/Style"; |
| | | import OlStyleIcon from "ol/style/Icon"; |
| | | // // 用来添加相关文字描述的 |
| | | import OlStyleText from "ol/style/Text"; |
| | | import OlStyleFill from "ol/style/Fill"; |
| | | // import Cesium from "libs/Cesium/Cesium.js"; |
| | | |
| | | export default { |
| | | name: "MapInThere", |
| | | components: { |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | // gunAddlayer: new VectorLayer({ |
| | | // // 图标图层 |
| | | // zIndex: 22, |
| | | // source: new VectorSource(), |
| | | // }), |
| | | // peopleAddlayer: new VectorLayer({ |
| | | // // 图标图层 |
| | | // zIndex: 22, |
| | | // source: new VectorSource(), |
| | | // }), |
| | | // carAddlayer: new VectorLayer({ |
| | | // // 图标图层 |
| | | // zIndex: 22, |
| | | // source: new VectorSource(), |
| | | // }), |
| | | // // peopleLineAddlayer: new VectorLayer({ |
| | | // // // 图标图层 |
| | | // // zIndex: 22, |
| | | // // source: new VectorSource(), |
| | | // // }), |
| | | // beginsPoint: new VectorLayer({ |
| | | // // 图标图层 |
| | | // zIndex: 22, |
| | | // source: new VectorSource(), |
| | | // }), |
| | | // DrawLayer: new VectorLayer({ |
| | | // // 图标图层 |
| | | // // zIndex: 1000, |
| | | // source: new VectorSource(), |
| | | // }), |
| | | toMoveTime: null, |
| | | oldService: "", |
| | | mapService: [ |
| | | // { |
| | | // id: "", |
| | | // value: "", |
| | | // show:'' |
| | | // }, |
| | | ], |
| | | mapService: [], |
| | | }; |
| | | }, |
| | | // computed: { |
| | | // mapServiceSee() { |
| | | // }, |
| | | // }, |
| | | // watch: { |
| | | // // openDrawChiose() { |
| | | // // console.log(this.openDrawChiose, "openDrawChiose"); |
| | | // // }, |
| | | // mapServiceValue: { |
| | | // handler(val) { |
| | | // // console.log("深度监听:", val); |
| | | // // this.checkDom("getMapDataRefs", (dom) => { |
| | | // // dom.setServiceData(this.mapServiceValue); |
| | | // // }); |
| | | // }, |
| | | // deep: true, |
| | | // }, |
| | | // }, |
| | | mounted() { |
| | | const ol2d = new OlMap({ |
| | | layers: [ |
| | | // new OlLayerTile({ |
| | | // zIndex: 4, |
| | | // title: "影像", |
| | | // source: new XYZ({ |
| | | // url: "https://webmap-tile.sf-express.com/MapTileService/rt?fetchtype=static&x={x}&y={y}&z={z}&project=sfmap&pic_size=256&pic_type=png8&data_name=361100&data_format=merged-dat&data_type=normal", // 行政区划 |
| | | // }), |
| | | // }), |
| | | // new OlLayerTile({ |
| | | // zIndex: 5, |
| | | // title: "道路+中文注记", |
| | | // source: new XYZ({ |
| | | // url: "http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0", // 注记 |
| | | // }), |
| | | // }), |
| | | new OlLayerTile({ |
| | | zIndex: 4, |
| | | title: "矢量", |
| | |
| | | window.ol2d = ol2d; |
| | | |
| | | var view = ol2d.getView(); |
| | | |
| | | // let provider = new Cesium.UrlTemplateImageryProvider({ |
| | | // url: "/wp/{z}/{x}/{y}.png", |
| | | // fileExtension: "png", |
| | | // }); |
| | | // view.imageryLayers.addImageryProvider(provider); |
| | | |
| | | // view.setCenter([115.85883507433789, 28.708432053474827]) |
| | | //设置中心点 |
| | | view.setCenter([114.03858862, 27.63088262]); |
| | | |
| | | // |
| | | //缩放范围 |
| | | view.setZoom(18); |
| | | this.view = view; |
| | | // const ol3d = new OLCesium({ map: window.ol2d }); |
| | |
| | | }, |
| | | methods: { |
| | | clearServiceData() { |
| | | //清空 |
| | | this.mapService = []; |
| | | }, |
| | | setServiceData(data) { |
| | |
| | | }), |
| | | // }), |
| | | }); |
| | | // console.log(data[data.length - 1].service); |
| | | // console.log(that.oldService); |
| | | // let str = ""; |
| | | // for (let k in that.oldService) { |
| | | // if (that.oldService[k] != data[data.length - 1].service[k]) { |
| | | // // console.log(that.oldService[k]); |
| | | // // console.log(data[data.length - 1].service[k]); |
| | | // str += that.oldService[k]; |
| | | // } |
| | | // } |
| | | // console.log("str", str); |
| | | // that.view.setCenter(layer); |
| | | let doit = () => { |
| | | this.toMoveTime = setTimeout(() => { |
| | | console.log(window.ol2d); |
| | |
| | | that.mapService.splice(that.$store.state.map.deleteIndex, 1); |
| | | } |
| | | } |
| | | // console.log(this.mapService); |
| | | // for() |
| | | }, |
| | | // addMapService(data) { |
| | | // let layer = new OlLayerTile({ |
| | | // // source: new XYZ({ |
| | | // // url: "http://mt3.google.cn/vt/lyrs=t&hl=zh-CN&gl=CN&src=app&x={x}&y={y}&z={z}&s=Ga", |
| | | // // }), |
| | | // // new OlLayerTile({ |
| | | // zIndex: 5, |
| | | // title: "中文注记", |
| | | // source: new XYZ({ |
| | | // url: "http://t3.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0", // 注记 |
| | | // }), |
| | | // // }), |
| | | // }); |
| | | // this.mapService.push({ |
| | | // layer: layer, |
| | | // }); |
| | | // window.ol2d.addLayer(layer); |
| | | // setTimeout(() => { |
| | | // window.ol2d.removeLayer(layer); |
| | | // }, 2000); |
| | | // }, |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | var extendStatics = function (d, b) { |
| | | extendStatics = |
| | | Object.setPrototypeOf || |
| | | ({ __proto__: [] } instanceof Array && |
| | | ({ |
| | | __proto__: [] |
| | | } |
| | | instanceof Array && |
| | | function (d, b) { |
| | | d.__proto__ = b; |
| | | }) || |
| | |
| | | "Class extends value " + String(b) + " is not a constructor or null" |
| | | ); |
| | | extendStatics(d, b); |
| | | |
| | | function __() { |
| | | this.constructor = d; |
| | | } |
| | | d.prototype = |
| | | b === null |
| | | ? Object.create(b) |
| | | : ((__.prototype = b.prototype), new __()); |
| | | b === null ? |
| | | Object.create(b) : |
| | | ((__.prototype = b.prototype), new __()); |
| | | }; |
| | | })(); |
| | | /** |
| | |
| | | import MultiPolygon from "ol/geom/MultiPolygon.js"; |
| | | import Point from "ol/geom/Point.js"; |
| | | import PointerInteraction from "ol/interaction/Pointer.js"; |
| | | import Polygon, { fromCircle, makeRegular } from "ol/geom/Polygon.js"; |
| | | import Polygon, { |
| | | fromCircle, |
| | | makeRegular |
| | | } from "ol/geom/Polygon.js"; |
| | | import VectorLayer from "ol/layer/Vector.js"; |
| | | import VectorSource from "ol/source/Vector.js"; |
| | | import { FALSE, TRUE } from "ol/functions.js"; |
| | | import { always, noModifierKeys, shiftKeyOnly } from "ol/events/condition.js"; |
| | | import { |
| | | FALSE, |
| | | TRUE |
| | | } from "ol/functions.js"; |
| | | import { |
| | | always, |
| | | noModifierKeys, |
| | | shiftKeyOnly |
| | | } from "ol/events/condition.js"; |
| | | import { |
| | | boundingExtent, |
| | | getBottomLeft, |
| | |
| | | getTopLeft, |
| | | getTopRight, |
| | | } from "ol/extent.js"; |
| | | import { createEditingStyle } from "ol/style/Style.js"; |
| | | import { fromUserCoordinate, getUserProjection } from "ol/proj.js"; |
| | | import { squaredDistance as squaredCoordinateDistance } from "ol/coordinate.js"; |
| | | import { |
| | | createEditingStyle |
| | | } from "ol/style/Style.js"; |
| | | import { |
| | | fromUserCoordinate, |
| | | getUserProjection |
| | | } from "ol/proj.js"; |
| | | import { |
| | | squaredDistance as squaredCoordinateDistance |
| | | } from "ol/coordinate.js"; |
| | | /** |
| | | * @typedef {Object} Options |
| | | * @property {import("ol/geom/GeometryType.js").default} type Geometry type of |
| | |
| | | } |
| | | return DrawEvent; |
| | | })(Event); |
| | | export { DrawEvent }; |
| | | export { |
| | | DrawEvent |
| | | }; |
| | | /*** |
| | | * @template Return |
| | | * @typedef {import("ol/Observable").OnSignature<import("ol/Observable").EventTypes, import("ol/events/Event.js").default, Return> & |
| | |
| | | */ |
| | | _this.coordinate = options.coordinate; |
| | | /*** |
| | | * 输出坐标 |
| | | * 输出坐标-自定义 |
| | | */ |
| | | _this.coordinateOver = options.coordinateOver; |
| | | /*** |
| | | * 结束绘画 |
| | | * 结束绘画-自定义 |
| | | */ |
| | | _this.overDraw = false; |
| | | /*** |
| | | * 控制结束绘画 |
| | | * 控制结束绘画-自定义 |
| | | */ |
| | | _this.isPoint = options.isPoint; |
| | | /*** |
| | | * 是否是点 |
| | | * 是否是点-自定义 |
| | | */ |
| | | _this.coordinateOverPoint = options.coordinateOverPoint; |
| | | /*** |
| | | * 输出点 |
| | | * 输出点-自定义 |
| | | */ |
| | | _this.on; |
| | | /*** |
| | |
| | | * @type {number} |
| | | * @private |
| | | */ |
| | | _this.minPoints_ = options.minPoints |
| | | ? options.minPoints |
| | | : _this.mode_ === Mode.POLYGON |
| | | ? 3 |
| | | : 2; |
| | | _this.minPoints_ = options.minPoints ? |
| | | options.minPoints : |
| | | _this.mode_ === Mode.POLYGON ? |
| | | 3 : |
| | | 2; |
| | | /** |
| | | * The number of points that can be drawn before a polygon ring or line string |
| | | * is finished. The default is no restriction. |
| | |
| | | * @private |
| | | */ |
| | | _this.maxPoints_ = |
| | | _this.mode_ === Mode.CIRCLE |
| | | ? 2 |
| | | : options.maxPoints |
| | | ? options.maxPoints |
| | | : Infinity; |
| | | _this.mode_ === Mode.CIRCLE ? |
| | | 2 : |
| | | options.maxPoints ? |
| | | options.maxPoints : |
| | | Infinity; |
| | | /** |
| | | * A function to decide if a potential finish coordinate is permissible |
| | | * @private |
| | | * @type {import("ol/events/condition.js").Condition} |
| | | */ |
| | | _this.finishCondition_ = options.finishCondition |
| | | ? options.finishCondition |
| | | : TRUE; |
| | | _this.finishCondition_ = options.finishCondition ? |
| | | options.finishCondition : |
| | | TRUE; |
| | | var geometryFunction = options.geometryFunction; |
| | | if (!geometryFunction) { |
| | | var mode_1 = _this.mode_; |
| | |
| | | * @return {import("ol/geom/SimpleGeometry.js").default} A geometry. |
| | | */ |
| | | geometryFunction = function (coordinates, geometry, projection) { |
| | | var circle = geometry |
| | | ? /** @type {Circle} */ (geometry) |
| | | : new Circle([NaN, NaN]); |
| | | var circle = geometry ? |
| | | /** @type {Circle} */ |
| | | (geometry) : |
| | | new Circle([NaN, NaN]); |
| | | var center = fromUserCoordinate(coordinates[0], projection); |
| | | var squaredLength = squaredCoordinateDistance( |
| | | center, |
| | |
| | | * @type {number} |
| | | * @private |
| | | */ |
| | | _this.squaredClickTolerance_ = options.clickTolerance |
| | | ? options.clickTolerance * options.clickTolerance |
| | | : 36; |
| | | _this.squaredClickTolerance_ = options.clickTolerance ? |
| | | options.clickTolerance * options.clickTolerance : |
| | | 36; |
| | | /** |
| | | * Draw overlay where our sketch features are drawn. |
| | | * @type {VectorLayer} |
| | |
| | | if (options.freehand) { |
| | | _this.freehandCondition_ = always; |
| | | } else { |
| | | _this.freehandCondition_ = options.freehandCondition |
| | | ? options.freehandCondition |
| | | : shiftKeyOnly; |
| | | _this.freehandCondition_ = options.freehandCondition ? |
| | | options.freehandCondition : |
| | | shiftKeyOnly; |
| | | } |
| | | _this.addChangeListener(InteractionProperty.ACTIVE, _this.updateState_); |
| | | return _this; |
| | |
| | | var dx = downPx[0] - clickPx[0]; |
| | | var dy = downPx[1] - clickPx[1]; |
| | | var squaredDistance = dx * dx + dy * dy; |
| | | this.shouldHandle_ = this.freehand_ |
| | | ? squaredDistance > this.squaredClickTolerance_ |
| | | : squaredDistance <= this.squaredClickTolerance_; |
| | | this.shouldHandle_ = this.freehand_ ? |
| | | squaredDistance > this.squaredClickTolerance_ : |
| | | squaredDistance <= this.squaredClickTolerance_; |
| | | if (!this.shouldHandle_) { |
| | | return; |
| | | } |
| | |
| | | if (this.mode_ === Mode.POINT) { |
| | | this.sketchCoords_ = start.slice(); |
| | | } else if (this.mode_ === Mode.POLYGON) { |
| | | this.sketchCoords_ = [[start.slice(), start.slice()]]; |
| | | this.sketchCoords_ = [ |
| | | [start.slice(), start.slice()] |
| | | ]; |
| | | this.sketchLineCoords_ = this.sketchCoords_[0]; |
| | | } else { |
| | | this.sketchCoords_ = [start.slice(), start.slice()]; |
| | |
| | | last[0] = coordinate[0]; |
| | | last[1] = coordinate[1]; |
| | | this.geometryFunction_( |
| | | /** @type {!LineCoordType} */ (this.sketchCoords_), |
| | | /** @type {!LineCoordType} */ |
| | | (this.sketchCoords_), |
| | | geometry, |
| | | projection |
| | | ); |
| | |
| | | this.geometryFunction_(coordinates, geometry, projection); |
| | | } else if (this.mode_ === Mode.POLYGON) { |
| | | // remove the redundant last point in ring |
| | | /** @type {PolyCoordType} */ (coordinates)[0].pop(); |
| | | /** @type {PolyCoordType} */ |
| | | (coordinates)[0].pop(); |
| | | this.geometryFunction_(coordinates, geometry, projection); |
| | | coordinates = geometry.getCoordinates(); |
| | | } |
| | |
| | | sketchCoords = /** @type {LineCoordType} */ (this.sketchCoords_); |
| | | } else if (mode === Mode.POLYGON) { |
| | | sketchCoords = |
| | | this.sketchCoords_ && this.sketchCoords_.length |
| | | ? /** @type {PolyCoordType} */ (this.sketchCoords_)[0] |
| | | : []; |
| | | this.sketchCoords_ && this.sketchCoords_.length ? |
| | | /** @type {PolyCoordType} */ |
| | | (this.sketchCoords_)[0] : []; |
| | | } else { |
| | | return; |
| | | } |
| | |
| | | export function createRegularPolygon(opt_sides, opt_angle) { |
| | | return function (coordinates, opt_geometry, projection) { |
| | | var center = fromUserCoordinate( |
| | | /** @type {LineCoordType} */ (coordinates)[0], |
| | | /** @type {LineCoordType} */ |
| | | (coordinates)[0], |
| | | projection |
| | | ); |
| | | var end = fromUserCoordinate( |
| | | /** @type {LineCoordType} */ (coordinates)[coordinates.length - 1], |
| | | /** @type {LineCoordType} */ |
| | | (coordinates)[coordinates.length - 1], |
| | | projection |
| | | ); |
| | | var radius = Math.sqrt(squaredCoordinateDistance(center, end)); |
| | | var geometry = opt_geometry |
| | | ? /** @type {Polygon} */ (opt_geometry) |
| | | : fromCircle(new Circle(center), opt_sides); |
| | | var geometry = opt_geometry ? |
| | | /** @type {Polygon} */ |
| | | (opt_geometry) : |
| | | fromCircle(new Circle(center), opt_sides); |
| | | var angle = opt_angle; |
| | | if (!opt_angle && opt_angle !== 0) { |
| | | var x = end[0] - center[0]; |
| | |
| | | export function createBox() { |
| | | return function (coordinates, opt_geometry, projection) { |
| | | var extent = boundingExtent( |
| | | /** @type {LineCoordType} */ ([ |
| | | /** @type {LineCoordType} */ |
| | | ([ |
| | | coordinates[0], |
| | | coordinates[coordinates.length - 1], |
| | | ]).map(function (coordinate) { |
| | |
| | | } else { |
| | | this.notNow = true; |
| | | } |
| | | //notNow来确定是修改值还是增加值 是否显示$("#dataConfirm").show(100); |
| | | this.nowIndex = num; |
| | | if (val.indexOf("路径") != -1) { |
| | | // console.log("加载路径按钮"); |
| | |
| | | } |
| | | }, |
| | | controlBut(openName, notNow) { |
| | | //判断哪个dom打开 |
| | | this.closeOurBut(); |
| | | this[openName] = true; |
| | | $("#" + openName).show(); |
| | |
| | | } |
| | | }, |
| | | closeOurBut(open) { |
| | | //整体关闭dom |
| | | $("#dataConfirm").hide(); |
| | | $("#openDrawPoint").hide(); |
| | | $("#openDrawLine").hide(); |
| | |
| | | <baseMapMap |
| | | ref="baseMapMap" |
| | | id="baseMapMap" |
| | | @setMapData="setMapData" |
| | | @changeMapSI="changeMapSI" |
| | | ></baseMapMap> |
| | | </template> |
| | |
| | | this.mapServiceValueOnce = ""; |
| | | this.chouseBaseMapNameOnce = ""; |
| | | }, |
| | | setMapData(val) { |
| | | this.LineData = val[0]; |
| | | this.PointData = val[1]; |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | if (row.haveBaseMap == "") { |
| | | this.$message({ |
| | |
| | | let names = "", |
| | | urls = "", |
| | | leng = this.mapServiceValue.length - 1; |
| | | //处理结果 |
| | | for (let k in this.mapServiceValue) { |
| | | names += this.mapServiceValue[k].name; |
| | | urls += this.mapServiceValue[k].service; |
| | |
| | | that.ourDatas[k].id = +k + 1; |
| | | } |
| | | } |
| | | //判断dom是否存在 |
| | | this.checkDom("getMapDataRefs", (dom) => { |
| | | //提供数据 |
| | | dom.onceOnlodad(that.ourDatas); |
| | | }); |
| | | this.nowId = +this.ourDatas.length + 1; |
| | | }, |
| | | methods: { |
| | | openDrawLineMethod() { |
| | | //添加线路的对象 |
| | | let id = this.nowId++; |
| | | this.ourDatas.push({ |
| | | label: "路径" + +id, |
| | | value: "", |
| | | name: "", |
| | | notPath: false, |
| | | //notpath判断是否验证通过的提示 2 为不通过 |
| | | isLine: true, |
| | | //isLine来判断是否是线 |
| | | id: +id, |
| | | //id确定不重复 |
| | | }); |
| | | }, |
| | | openDrawPointMethod() { |
| | | //添加点的对象 |
| | | let id = this.nowId++; |
| | | this.ourDatas.push({ |
| | | label: "标点" + +id, |
| | |
| | | }); |
| | | }, |
| | | deleteRowOurs(index) { |
| | | //删除 |
| | | this.ourDatas.splice(index, 1); |
| | | }, |
| | | backMapDataOurData(val, index) { |
| | | //在地图内useMapData方法中触发 |
| | | if (val == "line") { |
| | | this.ourDatas[index].value = this.rotesData; |
| | | } else if (val == "point") { |
| | |
| | | //以上是添加数据集方法 |
| | | //选择map数据 |
| | | openMap(val, num, value) { |
| | | //开始对地图做操作 |
| | | this.MapDataShow = true; |
| | | this.openTitle = val; |
| | | this.$refs.getMapDataRefs.init(val, num, value); |