.net webim 源码_arcgis api 4.x for js 集成 Echarts4 实现模拟迁徙图效果(附源码下载)...

54724ec19a3c65849390630ecf09773e.png

前言

关于本篇功能实现用到的 api 涉及类看不懂的,请参照 esri 官网的 arcgis api 4.x for js:esri 官网 api,里面详细的介绍 arcgis api 4.x 各个类的介绍,还有就是在线例子:esri 官网在线例子,这个也是学习 arcgis api 4.x 的好素材。

arcgis api 4.x for js 集成 echarts 实现迁徙图效果的关键问题在于 echarts 坐标系以及 arcgis 坐标系不一致,因此要进行 echarts坐标系与 arcgis 坐标系的转换,这里采用的方法是注册一个坐标系统命名为 arcgis(名称可自由拟定)的坐标系。在此基础上,采用 dojo 的 define 定义了一个名为 EchartsLayer 的模块。

参考资料 https:// blog.csdn.net/weixin_39 676449/article/details/82155812 https:// blog.csdn.net/yy2848724 97/article/details/85228643 https:// github.com/xcsf/ArcGIS- API-for-JS-with-Echarts
define(["dojo/_base/declare", "dojo/_base/lang", "esri/geometry/Point", "esri/geometry/SpatialReference"],
    function (declare, lang, n, SpatialReference) {
        return declare("EchartsLayer", null, {
            name:"EchartsLayer",
            view: null,
            box: null,
            chart: null,
            chartOption: null,
            visible:true,
            constructor: function (view, option) {

                echarts.registerCoordinateSystem('arcgis', this.getE3CoordinateSystem(view));
                this.init(view,option);
            },
            init:function(view, option) {
                this.setBaseMap(view);
                this.createLayer();
                //this.setChartOption(option);

            },
……

最终实现效果图:

2D 视图效果

55b58324a7347b2539f28fe6f780eda2.png
3D 视图效果

a7260d4d54ff1df716dad6dad0047152.png
创建 EchartsLayer 模块的构造函数,需要注册 arcgis 坐标系函数
//需要先引用echarts.js 
echarts.registerCoordinateSystem('arcgis', this.defineCoordinateSystem(view)); 
在 defineCoordinateSystem() 函数中,对 echarts 里面的几个函数进行了重写,其中主要包含 dataToPoint、pointToData 等坐标转换内容。
  • dataToPoint 函数重写
CoordSystem.prototype.dataToPoint = function dataToPoint(data) { 
 var point  = { 
 type:"point", 
 x:data[0], 
 y:data[1], 
 spatialReference:new SpatialReference(4326) 
              }; 
 var px = map.toScreen(point); 
 var mapOffset = this._mapOffset; 
 return [px.x - mapOffset[0], px.y - mapOffset[1]]; 
} 

更多的详情见

arcgis api 4.x for js 集成 Echarts4 实现模拟迁徙图效果(附源码下载) - 小专栏​xiaozhuanlan.com
9c753f80d5d5e401172dd85d447441f0.png

文章尾部提供源代码下载,对本专栏感兴趣的话,可以关注一波


GIS之家店铺:GIS之家
GIS之家源码咨询:GIS之家webgis入门开发系列demo源代码咨询

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值