arcgis js 4 完美支持mapV ,动画也支持(一)
之前我也看过有人弄过mapv和arcgis结合,但是还是不太完美,对于部分效果是不支持的比如动画,因此我自己弄一个arcgis版本的mapV出来
首先我们这次不是做插件 而是改造mapV, 去github 把整个mapV 下下来, 在mapV 构建两个类
首先是MapVRenderer.js 类
```javascript
import BaseLayer from "../../map/BaseLayer";
import DataSet from "../../data/DataSet";
export class MapVRenderer extends BaseLayer {
/**
- Creates an instance of MapVRenderer.
- @param {*} viewer cesium viewer
- @param {*} dataset mapv dataset
- @param {*} option mapvOptions
- @param {*} mapVLayer
- @memberof MapVRenderer
*/
constructor(viewer, dataset, option, mapVLayer) {
super(viewer, dataset, option)
if (!BaseLayer) {
return;
}
this.map = viewer,
// this.scene = viewer.scene,
this.dataSet = new DataSet(dataset);
option = option || {},
this.init(option),
this.argCheck(option),
this.initDevicePixelRatio(),
this.canvasLayer = mapVLayer,
this.stopAniamation = !1,
this.animation = option.animation,
this.clickEvent = this.clickEvent.bind(this),
this.mousemoveEvent = this.mousemoveEvent.bind(this),
this.bindEvent()
}
initDevicePixelRatio() {
this.devicePixelRatio = window.devicePixelRatio || 1
}
clickEvent(t) {
var e = t.point;
super.clickEvent(e, t)
}
mousemoveEvent(t) {
var e = t.point;
super.mousemoveEvent(e, t)
}
addAnimatorEvent() { }
animatorMovestartEvent() {
var t = this.options.animation;
this.isEnabledTime() && this.animator && (this.steps.step = t.stepsRange.start)
}
animatorMoveendEvent() {
this.isEnabledTime() && this.animator
}
bindEvent() {
this.map;
this.options.methods && (this.options.methods.click,
this.options.methods.mousemove)
}
unbindEvent() {
var t = this.map;
this.options.methods && (this.options.methods.click && t.off("click", this.clickEvent),
this.options.methods.mousemove && t.off("mousemove", this.mousemoveEvent))
}
getContext() {
return this.canvasLayer.canvas.getContext(this.context)
}
init(t) {
this.options = t,
this.initDataRange(t),
this.context = this.options.context || "2d",
this.options.zIndex && this.canvasLayer && this.canvasLayer.setZIndex(this.options.zIndex),
this.initAnimator()
}
_canvasUpdate(t) {
this.map;
let view = this.map;
var e = this.scene;
if (this.canvasLayer && !this.stopAniamation) {
var i = this.options.animation
, n = this.getContext();
if (this.isEnabledTime()) {
if (void 0 === t)
return void this.clear(n);
"2d" === this.context && (n.save(),
n.globalCompositeOperation = "destination-out",
n.fillStyle = "rgba(0, 0, 0, .1)",
n.fillRect(0, 0, n.canvas.width, n.canvas.height),
n.restore())
} else
this.clear(n);
if ("2d" === this.context)
for (var o in this.options)
n[o] = this.options[o];
else
n.clear(n.COLOR_BUFFER_BIT);
var a = {
transferCoordinate: (t)=> {
debugger
let coordinateType = this.getXYType(t[0],t[1]);
let coordXY = this.getRealXY(t[0],t[1],coordinateType);
let mapPoint = {
x: coordXY.x,
y: coordXY.y,
spatialReference: view.spatialReference
};
let screenPoint = view.toScreen(mapPoint);
return void 0 == n ? [-1, -1] : [screenPoint.x, screenPoint.y]
}
};
void 0 !== t && (a.filter = function (e) {
var n = i.trails || 10;
return !!(t && e.time > t - n && e.time < t)
}
);
var c = this.dataSet.get(a);
更多消息参考https://xiaozhuanlan.com/topic/9052637481
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律