代码迁移
This commit is contained in:
247
src/Obj/Base/ItineraryMove/index.js
Normal file
247
src/Obj/Base/ItineraryMove/index.js
Normal file
@ -0,0 +1,247 @@
|
||||
// /**
|
||||
// * @description 动态线
|
||||
// */
|
||||
// import FlowPictureMaterialProperty from '../../Materail/FlowPictureMaterialProperty'
|
||||
// import Dialog from '../../Element/Dialog';
|
||||
// import cy_slider from "../../Element/cy_html_slider";
|
||||
// import Base from "../index";
|
||||
|
||||
// class ItineraryMove extends Base {
|
||||
// /**
|
||||
// * @constructor
|
||||
// * @param sdk
|
||||
// * @param options {object} 线属性
|
||||
// * @param options.name{string} 名称
|
||||
// * @param options.image{string | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} 指定 Image、URL、Canvas 或 Video 的属性
|
||||
// * @param options.width=10{number} 线宽
|
||||
// * @param options.duration=500{number} 移动速度
|
||||
// * @param {Array.<number>} options.positions 经度、纬度和高度的列表[{经度,纬度,高度},{经度,纬度,高度}...]
|
||||
// * */
|
||||
// constructor(sdk, options = {}) {
|
||||
// super(sdk, options);
|
||||
// this.options.name = options.name || ''
|
||||
// this.options.image = options.image || this.getSourceRootPath() + '/img/arrowRoad.jpg'
|
||||
// this.options.width = (options.width || options.width === 0) ? options.width : 10
|
||||
// this.options.space = (options.space || options.space === 0) ? options.space : 1
|
||||
// this.options.backgroundColor = options.backgroundColor || "#ff000000"
|
||||
// this.options.duration = options.duration || options.duration === 0 || 500
|
||||
// ItineraryMove.create(this)
|
||||
// }
|
||||
|
||||
// static create(that) {
|
||||
// let positions = that.options.positions
|
||||
// let fromDegreesArray = []
|
||||
// for (let i = 0; i < positions.length; i++) {
|
||||
// fromDegreesArray.push(positions[i].lng, positions[i].lat)
|
||||
// }
|
||||
// const canvasEle = document.createElement('canvas');
|
||||
// const ctx = canvasEle.getContext('2d')
|
||||
// const myImg = new Image()
|
||||
// myImg.src = that.options.image
|
||||
// myImg.onload = function () {
|
||||
// canvasEle.width = myImg.width * (that.options.space + 1)
|
||||
// canvasEle.height = myImg.height
|
||||
// ctx.drawImage(myImg, myImg.width * (that.options.space / 2), 0)
|
||||
// that.entity = new Cesium.EntityCollection();
|
||||
// let imgEntity = that.sdk.viewer.entities.add({
|
||||
// name: 'imgEntity',
|
||||
// polyline: {
|
||||
// positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
||||
// // height: 1,
|
||||
// width: that.options.width,
|
||||
// clampToGround: true,
|
||||
// material: new FlowPictureMaterialProperty({
|
||||
// image: canvasEle,
|
||||
// repeat: new Cesium.CallbackProperty(function () {
|
||||
// var positionProperty = imgEntity.polyline.positions;
|
||||
// var positions = positionProperty.getValue(that.sdk.viewer.clock.currentTime);
|
||||
|
||||
// if (!Cesium.defined(positions)) {
|
||||
// return new Cesium.Cartesian2(1.0, 1.0);
|
||||
// }
|
||||
|
||||
// var distance = 0;
|
||||
// for (var i = 0; i < positions.length - 1; ++i) {
|
||||
// distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||
// }
|
||||
|
||||
// var repeatX = distance / imgEntity.polyline.width.getValue();
|
||||
// // 根据地图缩放程度调整repeatX
|
||||
// var cameraHeight = that.sdk.viewer.camera.positionCartographic.height;
|
||||
// var boundingSphere = new Cesium.BoundingSphere(
|
||||
// new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
||||
// 500000 // 半径(距离)
|
||||
// );
|
||||
|
||||
// // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||
// var drawingBufferWidth = that.sdk.viewer.canvas.clientWidth;
|
||||
// var drawingBufferHeight = that.sdk.viewer.canvas.clientHeight;
|
||||
|
||||
// // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||
// var groundResolution = that.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight)
|
||||
// repeatX *= groundResolution / cameraHeight / (that.options.space * (canvasEle.width / canvasEle.height * 5) + 1);
|
||||
// // if (repeatX < 3) {
|
||||
// // repeatX = 3
|
||||
// // }
|
||||
// return new Cesium.Cartesian2(repeatX, 1.0);
|
||||
// }, false),
|
||||
// duration: that.options.duration,
|
||||
// zIndex: that.sdk._entityZIndex,
|
||||
// })
|
||||
// // material: new Cesium.ImageMaterialProperty(
|
||||
// // {
|
||||
// // image: this.options.image,
|
||||
// // repeat: new Cesium.CallbackProperty(function () {
|
||||
// // var positionProperty = _this.entity.polyline.positions;
|
||||
// // var positions = positionProperty.getValue(_this.sdk.viewer.clock.currentTime);
|
||||
|
||||
// // if (!Cesium.defined(positions)) {
|
||||
// // return new Cesium.Cartesian2(1.0, 1.0);
|
||||
// // }
|
||||
|
||||
// // var distance = 0;
|
||||
// // for (var i = 0; i < positions.length - 1; ++i) {
|
||||
// // distance += Cesium.Cartesian3.distance(positions[i], positions[i + 1]);
|
||||
// // }
|
||||
|
||||
// // var repeatX = distance / _this.entity.polyline.width.getValue();
|
||||
// // // 根据地图缩放程度调整repeatX
|
||||
// // var cameraHeight = _this.sdk.viewer.camera.positionCartographic.height;
|
||||
// // var boundingSphere = new Cesium.BoundingSphere(
|
||||
// // new Cesium.Cartesian3(-1000000, 0, 0), // 中心点坐标
|
||||
// // 500000 // 半径(距离)
|
||||
// // );
|
||||
|
||||
// // // 获取绘图缓冲区的宽度和高度(通常是屏幕的分辨率)
|
||||
// // var drawingBufferWidth = _this.sdk.viewer.canvas.clientWidth;
|
||||
// // var drawingBufferHeight = _this.sdk.viewer.canvas.clientHeight;
|
||||
|
||||
// // // 使用 getPixelSize 方法获取包围球在屏幕上的像素大小
|
||||
// // var groundResolution = _this.sdk.viewer.scene.camera.getPixelSize(boundingSphere, drawingBufferWidth, drawingBufferHeight);
|
||||
// // repeatX *= groundResolution / cameraHeight / (Math.abs(_this.sdk.viewer.camera.pitch) + 1);
|
||||
// // if (repeatX < 3) {
|
||||
// // repeatX = 3
|
||||
// // }
|
||||
// // return new Cesium.Cartesian2(repeatX, 1.0);
|
||||
// // }, false),
|
||||
// // }
|
||||
// // )
|
||||
// },
|
||||
// })
|
||||
// that.sdk._entityZIndex ++
|
||||
// let lineEntity = that.sdk.viewer.entities.add({
|
||||
// name: 'lineEntity',
|
||||
// polyline: {
|
||||
// positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
||||
// width: that.options.width,
|
||||
// clampToGround: true,
|
||||
// material: Cesium.Color.fromCssColorString(that.options.backgroundColor),
|
||||
// zIndex: that.sdk._entityZIndex,
|
||||
// },
|
||||
// })
|
||||
// that.sdk._entityZIndex ++
|
||||
|
||||
// // let geojson = {
|
||||
// // type: "FeatureCollection",
|
||||
// // features: [
|
||||
// // {
|
||||
// // type: "Feature",
|
||||
// // geometry: {
|
||||
// // type: "LineString",
|
||||
// // coordinates: [
|
||||
// // [100.0, 40],
|
||||
// // [110.0, 40],
|
||||
// // [120.0, 40],
|
||||
// // ],
|
||||
// // },
|
||||
// // properties: { color: '#00c311' }
|
||||
// // },
|
||||
// // {
|
||||
// // type: "Feature",
|
||||
// // geometry: {
|
||||
// // type: "LineString",
|
||||
// // coordinates: [
|
||||
// // [120.0, 70],
|
||||
// // [130.0, 70],
|
||||
// // [140.0, 40],
|
||||
// // ],
|
||||
// // },
|
||||
// // properties: { color: '#ff0000' }
|
||||
// // }
|
||||
// // ]
|
||||
// // }
|
||||
// // var positions = [];
|
||||
// // var colors = [];
|
||||
// // for (var i = 0; i < geojson.features.length; i++) {
|
||||
// // for(let m = 0; m<geojson.features[i].geometry.coordinates.length;m++) {
|
||||
// // positions.push(Cesium.Cartesian3.fromDegrees(...geojson.features[i].geometry.coordinates[m]));
|
||||
// // colors.push(Cesium.Color.fromCssColorString(geojson.features[i].properties.color));
|
||||
// // }
|
||||
// // }
|
||||
|
||||
|
||||
// // this.entity = this.sdk.viewer.scene.primitives.add(new Cesium.Primitive({//GroundPrimitive贴地
|
||||
// // geometryInstances: new Cesium.GeometryInstance({
|
||||
// // geometry: new Cesium.CorridorGeometry({
|
||||
// // positions: Cesium.Cartesian3.fromDegreesArray(fromDegreesArray),
|
||||
// // width: this.options.width,
|
||||
// // height: this.options.height,
|
||||
// // cornerType: Cesium.CornerType.MITERED,
|
||||
// // vertexFormat: Cesium.MaterialAppearance.MaterialSupport.ALL.vertexFormat
|
||||
// // }),
|
||||
// // attributes: {
|
||||
// // color: Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 1.0, 1.0, 0.5))
|
||||
// // }
|
||||
// // }),
|
||||
// // appearance: new Cesium.MaterialAppearance({
|
||||
// // material: Cesium.Material.fromType('Image', {
|
||||
// // image: this.options.image,
|
||||
// // repeat: new Cesium.Cartesian2(100, 1.0)
|
||||
// // }),
|
||||
// // faceForward: true,
|
||||
// // renderState: {
|
||||
// // blending: Cesium.BlendingState.ALPHA_BLEND
|
||||
// // }
|
||||
// // })
|
||||
// // }));
|
||||
// // const instance = new Cesium.GeometryInstance({
|
||||
// // geometry : new Cesium.GroundPolylineGeometry({
|
||||
// // positions : Cesium.Cartesian3.fromDegreesArray([
|
||||
// // -112.1340164450331, 36.05494287836128,
|
||||
// // -112.08821010582645, 36.097804071380715
|
||||
// // ]),
|
||||
// // width : 4.0
|
||||
// // }),
|
||||
// // id : 'object returned when this instance is picked and to get/set per-instance attributes'
|
||||
// // });
|
||||
|
||||
// // _this.sdk.viewer.scene.groundPrimitives.add(new Cesium.GroundPolylinePrimitive({
|
||||
// // geometryInstances: new Cesium.GeometryInstance({
|
||||
// // geometry: new Cesium.GroundPolylineGeometry({
|
||||
// // positions: positions,
|
||||
// // width: 40.0,
|
||||
// // colors : colors
|
||||
// // })
|
||||
// // }),
|
||||
// // appearance: new Cesium.PolylineMaterialAppearance()
|
||||
// // }));
|
||||
// // console.log('entity', _this.entity)
|
||||
// that.entity.add(imgEntity)
|
||||
// that.entity.add(lineEntity)
|
||||
// that.sdk.viewer.entities.add(that.entity)
|
||||
// }
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * 删除
|
||||
// */
|
||||
// remove() {
|
||||
// for (let i = 0; i < this.entity.values.length; i++) {
|
||||
// this.sdk.viewer.entities.remove(this.entity.values[i])
|
||||
// }
|
||||
// this.entity.removeAll()
|
||||
// this.entity = null
|
||||
// }
|
||||
// }
|
||||
|
||||
// export default ItineraryMove
|
Reference in New Issue
Block a user