openlayers 热力图 天地图

openlayers 实现热力图 样式可调
https://blog.csdn.net/qq_36287830/article/details/131844745?spm=1001.2014.3001.5501基础上改进来的
在这里插入图片描述

关键代码
如果你有数据可以不使用for循环

 var blurInput = document.getElementById("blur");
            var rediusInput = document.getElementById("radius");
            var heatmapData = [];
            for (var i = 0; i < 1000; i++) {
                heatmapData.push([
                    Math.random() * 360 - 180, // 随机经度
                    Math.random() * 180 - 90, // 随机纬度
                    Math.random(), // 随机权重
                ]);
            }
            let pointHost = new ol.layer.Heatmap({//热力图图层
                source: new ol.source.Vector({
                    features: heatmapData.map((item) => {
                        let feature = new ol.Feature({
                            geometry: new ol.geom.Point([item[0], item[1]]),
                        });
                        feature.set("weight", item[2] * 1.5);//权重
                        return feature;
                    }),
                }),
                blur: parseFloat(blurInput.value), // 模糊程度
                radius: parseFloat(rediusInput.value), // 半径
                zIndex: 5,//层级
            });
            map.addLayer(pointHost);
            blurInput.addEventListener("input", (target) => {
                pointHost.setBlur(parseFloat(target.target.value));
            });
            rediusInput.addEventListener("input", (target) => {
                pointHost.setRadius(parseFloat(target.target.value));
            });

相关推荐

  1. 山海鲸可视化——天地画面和力图

    2024-05-15 13:12:20       28 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-15 13:12:20       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-15 13:12:20       100 阅读
  3. 在Django里面运行非项目文件

    2024-05-15 13:12:20       82 阅读
  4. Python语言-面向对象

    2024-05-15 13:12:20       91 阅读

热门阅读

  1. Python3 笔记:range() 函数

    2024-05-15 13:12:20       29 阅读
  2. 【大数据面试题】27 讲下Doris的物化视图

    2024-05-15 13:12:20       33 阅读
  3. CentOS常用命令速览:把握Linux服务器的脉动

    2024-05-15 13:12:20       25 阅读
  4. Milvus 基本概念

    2024-05-15 13:12:20       28 阅读
  5. ListView[new]

    2024-05-15 13:12:20       32 阅读
  6. Linux监控apache脚本

    2024-05-15 13:12:20       30 阅读
  7. php8编译报错

    2024-05-15 13:12:20       36 阅读
  8. 自己设计扩散模型进行图生图

    2024-05-15 13:12:20       32 阅读
  9. WLAN技术

    2024-05-15 13:12:20       34 阅读
  10. 第一天:Docker入门与基础安装

    2024-05-15 13:12:20       33 阅读
  11. 升级openssl

    2024-05-15 13:12:20       32 阅读
  12. 48V磁吸灯智能调光照明驱动方案无频闪12V24V36V48V

    2024-05-15 13:12:20       25 阅读
  13. 面试 JVM 八股文十问十答第六期

    2024-05-15 13:12:20       35 阅读
  14. C# 不用lock写一个多线程程序

    2024-05-15 13:12:20       35 阅读