Cesium实现热力图功能

效果图如下:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Cesium热力图</title><!-- 在这里引入Cesium --><script src="./lib/Cesium/Cesium.js"></script><script src="./js/CesiumHeatmap.js"></script><link rel="stylesheet" href="./lib/Cesium/Widgets/widgets.css" rel="stylesheet"><style>html,body {margin: 0;padding: 0;}</style>
</head><body><!-- https://blog.csdn.net/weixin_45782925/article/details/123054390 --><!-- 放置地球的容器 --><div id="cesiumContainer"></div><!-- 设置token --><script>Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlMDczMzQ0NC1lZmRkLTQ0ODEtOGZhMy01MDU3NzAzM2E5YmIiLCJpZCI6MTg2MDgsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1NzQxNDMwNTB9.LJcpHG4SJ8DI1mCHd1aabofkvS-9WrxeWVul7Axw_Kw';</script><script>var viewer = new Cesium.Viewer('cesiumContainer', {// 关闭一些UIbaseLayerPicker: false, //右上角的图层选择按钮animation: true,        //左下角的动画仪表盘infoBox: false,         //点击要素之后显示的信息geocoder: false,        //搜索框homeButton: false,      //home按钮sceneModePicker: true,  //模式切换按钮timeline: true,         //底部的时间轴fullscreenButton: false,//右下角的全屏按钮shouldAnimate: true,navigationHelpButton: false, //右上角的帮助按钮});function testLoc() {// 设定热力图的四至范围let bounds = {west: 116.13833844,east: 116.13956899,south: 37.43582929,north: 37.43706916};// 初始化热力图let heatMap = CesiumHeatmap.create(viewer, // your cesium viewerbounds, // bounds for heatmap layer{// heatmap.js options go heremaxOpacity: 0.75});// 设置一些随机的效果,这个可根据实际数据进行开发let data = [{"x": 116.1383442264,"y": 37.4360048372,"value": 76}, {"x": 116.1384363011,"y": 37.4360298848,"value": 63}, {"x": 116.138368102,"y": 37.4358360603,"value": 1}, {"x": 116.1385627739,"y": 37.4358799123,"value": 21}, {"x": 116.1385138501,"y": 37.4359327669,"value": 28}, {"x": 116.1385031219,"y": 37.4359730105,"value": 41}, {"x": 116.1384127393,"y": 37.435928255,"value": 75}, {"x": 116.1384551116,"y": 37.4359450132,"value": 3}, {"x": 116.1384927196,"y": 37.4359158649,"value": 45}, {"x": 116.1384938639,"y": 37.4358498311,"value": 45}, {"x": 116.1385183299,"y": 37.4360213794,"value": 93}, {"x": 116.1384007925,"y": 37.4359860133,"value": 46}, {"x": 116.1383604844,"y": 37.4358298672,"value": 54}, {"x": 116.13851025,"y": 37.4359098303,"value": 39}, {"x": 116.1383874733,"y": 37.4358511035,"value": 34}, {"x": 116.1384981796,"y": 37.4359355403,"value": 81}, {"x": 116.1384504107,"y": 37.4360332348,"value": 39}, {"x": 116.1385582664,"y": 37.4359788335,"value": 20}, {"x": 116.1383967364,"y": 37.4360581999,"value": 35}, {"x": 116.1383839615,"y": 37.436016316,"value": 47}, {"x": 116.1384082712,"y": 37.4358423338,"value": 36}, {"x": 116.1385092651,"y": 37.4358577623,"value": 69}, {"x": 116.138360356,"y": 37.436046789,"value": 90}, {"x": 116.138471893,"y": 37.4359184292,"value": 88}, {"x": 116.1385605689,"y": 37.4360271359,"value": 81}, {"x": 116.1383585714,"y": 37.4359362476,"value": 32}, {"x": 116.1384939114,"y": 37.4358844253,"value": 67}, {"x": 116.138466724,"y": 37.436019121,"value": 17}, {"x": 116.1385504355,"y": 37.4360614056,"value": 49}, {"x": 116.1383883832,"y": 37.4358733544,"value": 82}, {"x": 116.1385670669,"y": 37.4359650236,"value": 25}, {"x": 116.1383416534,"y": 37.4359310876,"value": 82}, {"x": 116.138525285,"y": 37.4359394661,"value": 66}, {"x": 116.1385487719,"y": 37.4360137656,"value": 73}, {"x": 116.1385496029,"y": 37.4359187277,"value": 73}, {"x": 116.1383989222,"y": 37.4358556562,"value": 61}, {"x": 116.1385499424,"y": 37.4359149305,"value": 67}, {"x": 116.138404523,"y": 37.4359563326,"value": 90}, {"x": 116.1383883675,"y": 37.4359794855,"value": 78}, {"x": 116.1383967187,"y": 37.435891185,"value": 15}, {"x": 116.1384610005,"y": 37.4359044797,"value": 15}, {"x": 116.1384688489,"y": 37.4360396127,"value": 91}, {"x": 116.1384431875,"y": 37.4360684409,"value": 8}, {"x": 116.1385411067,"y": 37.4360645847,"value": 42}, {"x": 116.1385237178,"y": 37.4358843181,"value": 31}, {"x": 116.1384406464,"y": 37.4360003831,"value": 51}, {"x": 116.1384679169,"y": 37.4359950456,"value": 96}, {"x": 116.1384194314,"y": 37.4358419739,"value": 22}, {"x": 116.1385049792,"y": 37.4359574813,"value": 44}, {"x": 116.1384097378,"y": 37.4358598672,"value": 82}, {"x": 116.1384993219,"y": 37.4360352975,"value": 84}, {"x": 116.1383640499,"y": 37.4359839518,"value": 81}];//设置最大最小值let valueMin = 0;let valueMax = 100;// 将数据添加到热力图heatMap.setWGS84Data(valueMin, valueMax, data);//定位到热力图的位置viewer.zoomTo(viewer.entities);}// 方式一// testLoc()// 请求本地数据var hdata = nullasync function addHeatmap() {// 请求本地数据var data = nullawait fetch("./data/heatmap.json").then(res =>res.json()).then(d => {data = d})// random example data 添加数据 最小值,最大值,数据集 let valueMin = data[0].value;let valueMax = data[0].value;;let bounds = {west: data[0].x, south: data[0].y, east: data[0].x, north: data[0].y};// 初始化数据点范围		for (var i in data) {let _x = data[i].x;let _y = data[i].y;let _value = data[i].value;if (valueMin > _value) {valueMin = _value;}if (valueMax < _value) {valueMax = _value;}if (bounds.west > _x) {bounds.west = _x;}if (bounds.east < _x) {bounds.east = _x;}if (bounds.south > _y) {bounds.south = _y;}if (bounds.north < _y) {bounds.north = _y;}}// 初始化cesiumheatmap对象,传入相应的参数let heatMap = CesiumHeatmap.create(viewer, // 视图层bounds, // 矩形坐标{ // heatmap相应参数backgroundColor: "rgba(0,0,0,0)",radius: 25,maxOpacity: .5,minOpacity: 0,blur: .75});// add data to heatmapheatMap.setWGS84Data(valueMin, valueMax, data);//定位到热力图的位置viewer.zoomTo(viewer.entities);}addHeatmap(hdata)</script>
</body></html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/206732.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

经典双指针算法试题(二)

&#x1f4d8;北尘_&#xff1a;个人主页 &#x1f30e;个人专栏:《Linux操作系统》《经典算法试题 》《C》 《数据结构与算法》 ☀️走在路上&#xff0c;不忘来时的初心 文章目录 一、有效三角形的个数1、题目讲解2、讲解算法原理3、代码实现 二、查找总价格为目标值的两个商…

SSM之Mybatis框架

1 概述 1.1 什么是Mybayis 它是一款半自动的ORM持久层框架&#xff0c;具有较高的SQL灵活性&#xff0c;支持高级映射(一对一&#xff0c;一对多)&#xff0c;动态SQL&#xff0c;延迟加载和缓存等特性&#xff0c;但它的数据库无关性较低。 1.2 什么是ORM ORM&#xff08;…

FlinkCDC实现主数据与各业务系统数据的一致性(瀚高、TIDB)

文章末尾附有flinkcdc对应瀚高数据库flink-cdc-connector代码下载地址 1、业务需求 目前项目有主数据系统和N个业务系统,为保障“一数一源”,各业务系统表涉及到主数据系统的字段都需用主数据系统表中的字段进行实时覆盖,这里以某个业务系统的一张表举例说明:业务系统表Ta…

FindMy技术用于充电宝

充电宝是一种便捷的充电器&#xff0c;方便个人随身携带&#xff0c;能够自行储备电能&#xff0c;为主流电子设备提供充电服务。它广泛应用于没有外部电源供应的场所&#xff0c;例如旅行、户外活动或紧急情况下&#xff0c;为用户的手持设备提供持续的电力支持&#xff0c;确…

DDPM的学习

Denoising Model 首先是宏观理解一下 Denoising Model 的输入 去噪很多步&#xff0c;用的是同一个Denoising Model&#xff0c;但是输入图片可能差距很大。解决方法&#xff1a;给Denoising Model多输入一个变量&#xff0c;表示现在的去噪阶段&#xff0c;让Denoising Mod…

知虾shopee收费,多少钱一个月

在当今电商行业的竞争激烈的环境下&#xff0c;许多商家都在寻求更好的方式来推广和销售他们的产品。这就是为什么越来越多的商家选择使用知虾shopee这样的平台来展示和销售他们的商品。但是&#xff0c;对于许多商家来说&#xff0c;他们可能会对知虾shopee的收费情况感到好奇…

RubbleDB: CPU-Efficient Replication with NVMe-oF

RubbleDB: CPU-Efficient Replication with NVMe-oF 前言 这是ATC2023的文章&#xff0c;作者来自哥伦比亚大学这篇工作在LSM-tree多副本存储的场景下&#xff0c;利用NVMe-oF技术避免了LSM-tree副本上的重复合并&#xff0c;减少了CPU开销。 Introduction 为了提供高可用性…

【C++内存管理】

【本节目标】 1. C/C内存分布 2. C语言中动态内存管理方式 3. C中动态内存管理 4. operator new与operator delete函数 5. new和delete的实现原理 6. 定位new表达式(placement-new) 7. 常见面试题 1. C/C内存分布 我们先来看一下内存分布图。 【说明】&#xff1a;内存…

IDEA集成Git

一、配置Git忽略文件 例如&#xff1a;用eclipse创建的项目有其特定的文件&#xff0c;例如&#xff1a;.classpath,.project文件&#xff0c;而用IDEA创建的项目也有其特定的文件&#xff1a;.xml,.iml,.target,我们需要最好忽略他们。 为什么要忽略他们&#xff1f; 与项目…

[Linux] shell脚本之循环

一、循环定义 一组被重复执行的语句称之为 循环体,能否继续重复,决定循环的终止条件。 循环语句 是由循环体及循环的终止条件两部分组成的。 二、for循环 2.1 带列表循环 语法 for 变量名 in 取值列表do 命令序列 done 花括号用法&#xff1a; 花括号{ }和seq在for循环…

【React-Router】导航传参

1. searchParams 传参 // /page/Login/index.js import { Link, useNavigate } from react-router-dom const Login () > {const navigate useNavigate()return <div>登录页<button onClick{() > navigate(/article?id91&namejk)}>searchParams 传参…

11.6AOP

一.AOP是什么 是面向切面编程,是对某一类事情的集中处理. 二.解决的问题 三.AOP的组成 四.实现步骤 1.添加依赖(版本要对应): maven仓库链接 2.添加两个注解 3.定义切点 4.通知 5.环绕通知 五.excution表达式 六.AOP原理 1.建立在动态代理的基础上,对方法级别的拦截. 2. …