iClient模拟疫情变化过程

2024-02-25 09:18

本文主要是介绍iClient模拟疫情变化过程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

作者:lly

背景

为了方便直观的了解疫情的变化过程,我们使用iClien客户端专题图来动态展示疫情的变化。
首先我们来看一看实现效果:
在这里插入图片描述

一、数据制作

数据需要制作为以下格式,即每天对应一个属性字段,并填充相应的数据,例:

行政区划D25D26
四川12
湖北1020

二、字段查询

查询时间字段,用于专题图赋值

var param = new SuperMap.FieldParameters({datasource: "NCP",dataset: "China_Province_pg_1_2_1"});L.supermap.fieldService(dataUrl).getFields(param, function(serviceResult) {var innerHTML = serviceResult.result.fieldNames.join(', ');for(var i = 9; i < serviceResult.result.fieldNames.length; i++) {var monthCount=0;var dateTemp="月";var day="/";					    var filed=serviceResult.result.fieldNames[i];time.push(filed);}});

三、制作专题图

使用客户端分段专题图来制作,首先初始化图层,并设置style

themeLayer = L.supermap.rangeThemeLayer("ThemeLayer", {// 开启 hover 高亮效果isHoverAble: false,opacity: 1,alwaysMapCRS: true}).addTo(map);themeLayer.style = new SuperMap.ThemeStyle({stroke: true,strokeColor: '#f4f4f4',strokeWidth: 1});// 用于单值专题图的属性字段名称themeLayer.themeField = time[0];// 风格数组,设定值对应的样式themeLayer.styleGroups = [{start: 0,end: 1,style: {color: style[0]}}, {start: 1,end: 99,style: {color: style[1]}}, {start: 99,end: 499,style: {color: style[2]}}, {start: 499,end: 999,style: {color: style[3]}}, {start: 1000,end: 9999,style: {color: style[4]}}, {start: 9999,end: 99999999999999999,style: {color: style[5]}}];

通过SQL查询数据服务,查询出行政区划面

var getFeatureBySQLParams = new SuperMap.GetFeaturesBySQLParameters({queryParameter: new SuperMap.FilterParameter({name: "China_Province_pg_1_2_1@NCP",attributeFilter: "SMID > -1"}),toIndex: 500,datasetNames: ["NCP:China_Province_pg_1_2_1"]});L.supermap.featureService(dataUrl).getFeaturesBySQL(getFeatureBySQLParams, processComplete, SuperMap.DataFormat.ISERVER);

将查询结果加到地图,并解析相应返回值用于总数显示

searchData = serviceResult;var result = serviceResult.result;var data = result.features;if(result && result.features) {themeLayer.addFeatures(result.features);var count = 0;for(var i = 0; i < result.features.length; i++) {count += Number(data[i].fieldValues[9]);}}

设置div用于制作图例

	<div class="legend"><div class="content"><div class="color" style="background: rgb(244, 244, 244);"></div><div class="text">0</div></div><div class="content"><div class="color" style="background: rgb(253, 212, 158);"></div><div class="text">1-99</div></div><div class="content"><div class="color" style="background: rgb(253, 187, 132);"></div><div class="text">100-499</div></div><div class="content"><div class="color" style="background: rgb(252, 141, 89);"></div><div class="text">500-999</div></div><div class="content"><div class="color" style="background: rgb(239, 101, 72);"></div><div class="text">1000-9999</div></div><div class="content"><div class="color" style="background: rgb(215, 48, 31);"></div><div class="text">10000人或以上</div></div></div>

css设置图例样式

	.legend {position: absolute;bottom: 10px;left: 20px;z-index: 99999;}.legend .content {height: 12px;margin-bottom: 6px;}.legend .content .color {width: 16px;height: 12px;margin-bottom: -5px;}.text {position: relative;font-size: 12px;color: rgba(255, 255, 255, 0.85);margin-left: 20px;line-height: 0px;}

四、添加时间轴

	var chart = echarts.init(document.getElementById("timeE"));option = {baseOption: {timeline: {axisType: 'category',autoPlay: true,currentIndex:0,playInterval: 1000,data: dataTimer,label: {formatter: function(s) {return s;},color:'#dfdfdf'}}}};chart.setOption(option);

监听时间轴改变事件,刷新专题图,并将对应统计值显示在div中

		chart.on('timelinechanged', function(timeLineIndex) {themeLayer.themeField = time[timeLineIndex.currentIndex];themeLayer.redraw();var result = searchData.result;var data = result.features;if(result && result.features) {var count = 0;for(var i = 0; i < result.features.length; i++) {count += Number(data[i].fieldValues[9 + Number(timeLineIndex.currentIndex)]);}}$(".value").html(count);$(".subTitle").html("截止" + date[timeLineIndex.currentIndex])});

五、结语

至此,我们已实现全部效果,底图和标签可根据自身喜好进行更换,其中标签需新建窗格将其置于顶层,例:

map.createPane('labels');
map.getPane('labels').style.zIndex = 650;
L.supermap.tiledMapLayer(tapUrl, {transparent: true,pane: "labels"}).addTo(map);

数据及代码下载地址,提取码:zqrk

这篇关于iClient模拟疫情变化过程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/745041

相关文章

Redis中Hash从使用过程到原理说明

《Redis中Hash从使用过程到原理说明》RedisHash结构用于存储字段-值对,适合对象数据,支持HSET、HGET等命令,采用ziplist或hashtable编码,通过渐进式rehash优化... 目录一、开篇:Hash就像超市的货架二、Hash的基本使用1. 常用命令示例2. Java操作示例三

Redis中Set结构使用过程与原理说明

《Redis中Set结构使用过程与原理说明》本文解析了RedisSet数据结构,涵盖其基本操作(如添加、查找)、集合运算(交并差)、底层实现(intset与hashtable自动切换机制)、典型应用场... 目录开篇:从购物车到Redis Set一、Redis Set的基本操作1.1 编程常用命令1.2 集

Linux下利用select实现串口数据读取过程

《Linux下利用select实现串口数据读取过程》文章介绍Linux中使用select、poll或epoll实现串口数据读取,通过I/O多路复用机制在数据到达时触发读取,避免持续轮询,示例代码展示设... 目录示例代码(使用select实现)代码解释总结在 linux 系统里,我们可以借助 select、

k8s中实现mysql主备过程详解

《k8s中实现mysql主备过程详解》文章讲解了在K8s中使用StatefulSet部署MySQL主备架构,包含NFS安装、storageClass配置、MySQL部署及同步检查步骤,确保主备数据一致... 目录一、k8s中实现mysql主备1.1 环境信息1.2 部署nfs-provisioner1.2.

MyBatis/MyBatis-Plus同事务循环调用存储过程获取主键重复问题分析及解决

《MyBatis/MyBatis-Plus同事务循环调用存储过程获取主键重复问题分析及解决》MyBatis默认开启一级缓存,同一事务中循环调用查询方法时会重复使用缓存数据,导致获取的序列主键值均为1,... 目录问题原因解决办法如果是存储过程总结问题myBATis有如下代码获取序列作为主键IdMappe

linux部署NFS和autofs自动挂载实现过程

《linux部署NFS和autofs自动挂载实现过程》文章介绍了NFS(网络文件系统)和Autofs的原理与配置,NFS通过RPC实现跨系统文件共享,需配置/etc/exports和nfs.conf,... 目录(一)NFS1. 什么是NFS2.NFS守护进程3.RPC服务4. 原理5. 部署5.1安装NF

Java 单元测试之Mockito 模拟静态方法与私有方法最佳实践

《Java单元测试之Mockito模拟静态方法与私有方法最佳实践》本文将深入探讨如何使用Mockito来模拟静态方法和私有方法,结合大量实战代码示例,带你突破传统单元测试的边界,写出更彻底、更独立... 目录Mockito 简介:为什么选择它?环境准备模拟静态方法:打破“不可变”的枷锁传统困境解法一:使用M

MySQL使用EXISTS检查记录是否存在的详细过程

《MySQL使用EXISTS检查记录是否存在的详细过程》EXISTS是SQL中用于检查子查询是否返回至少一条记录的运算符,它通常用于测试是否存在满足特定条件的记录,从而在主查询中进行相应操作,本文给大... 目录基本语法示例数据库和表结构1. 使用 EXISTS 在 SELECT 语句中2. 使用 EXIS

oracle 11g导入\导出(expdp impdp)之导入过程

《oracle11g导入导出(expdpimpdp)之导入过程》导出需使用SEC.DMP格式,无分号;建立expdir目录(E:/exp)并确保存在;导入在cmd下执行,需sys用户权限;若需修... 目录准备文件导入(impdp)1、建立directory2、导入语句 3、更改密码总结上一个环节,我们讲了

ShardingProxy读写分离之原理、配置与实践过程

《ShardingProxy读写分离之原理、配置与实践过程》ShardingProxy是ApacheShardingSphere的数据库中间件,通过三层架构实现读写分离,解决高并发场景下数据库性能瓶... 目录一、ShardingProxy技术定位与读写分离核心价值1.1 技术定位1.2 读写分离核心价值二