当前位置: 首页 > article >正文

基于maobox-gl 纯前端绘制全球色斑图

基于maobox-gl.js、turf.js 绘制全球色斑图绘制

1、准备全球的某一类的点位数据,可以使用turf.js 随机生成点,并点数据赋properties属性

let points = turf.randomPoint(30, { bbox: [-180, -90, 180, 90]});
let interpolateOptions = {
  gridType: "points",
  property: "value",
  units: "degrees",
  weight: 10
};
let resultPoint = turf.interpolate(points, 0.5, interpolate_options);

2、结合第一步的点数据,取带有z值和一组值断点的点Feature的网格FeatureCollection,并生成填充的等边线

 let isobandsOptions = {
    zProperty: "result",
    commonProperties: {
      "fill-opacity": 0.6,
    },
    breaksProperties: [
      { fill: "#ffcc00" },
      { fill: "#baff00" },
      { fill: "#92ff00" },
      { fill: "#00ff36" },
      { fill: "#00ffae" },
      { fill: "#00d8ff" },
      { fill: "#3f00ff" },
      { fill: "#7b00ff" },
      { fill: "#cb00ff" },
    ],
  };
  let isobands: any = turf.isobands(
    grid,
    [2, 3, 4, 5, 6, 7, 8],
    isobandsOptions 
  );

3、加载结果数据

// 可视化部分
  const addIsobands = () => {
    map.addSource("intersection", {
      type: "geojson",
      data: isobands,
    });

    map.addLayer({
      id: "intersection",
      type: "fill",
      source: "intersection",
      layout: {},
      paint: {
        "fill-color": ["get", "fill"],
        "fill-opacity": [
          "case",
          ["boolean", ["feature-state", "hover"], false],
          0.8,
          0.5,
        ],
        "fill-outline-color": "transparent",
      },
    });
  };


http://www.kler.cn/news/156168.html

相关文章:

  • 布局问题1:addSpacing()和setSpacing()函数的区别?
  • C++服务器 支持http、tcp protobuf、websocket,linux开源框架 零依赖轻松编译部署 Reactor
  • nodejs实现文件/目录的压缩和解压
  • 【微信小程序】上传头像 微信小程序内接小程序客服
  • C++ day51 买卖股票最佳时期
  • 计算机网络——习题
  • 【PTA-C语言】编程练习3 - 循环结构Ⅱ
  • 安装配置JDK1.8
  • 单例模式的实现
  • 字符串转换整数
  • 一个完整的手工构建的cuda动态链接库工程 03记
  • SQL Server 2016(创建数据表)
  • qt-C++笔记之识别点击鼠标右键、点击位置以及Qt坐标系详解
  • flutter-web中使用js工具类
  • Linux系统配置深度学习环境之cudnn安装
  • 40 mysql join 的实现
  • jmeter下载地址
  • [Java] 模拟Jdk 以及 CGLib 代理原理
  • 网络接口规范
  • springBoot整合task
  • uniapp中uni.navigateBack返回后刷新页面数据
  • 线程池大小设置多少,比较合适?
  • 如何从 Jira 成功迁移到极狐GitLab,看这个就够了!
  • [leetcode 哈希表] 模版
  • AtCoder Beginner Contest 331 题解 A-E
  • postgreSQL 查询所有模式的语句
  • 算法设计与实现--动态规划篇
  • Matlab和python详解数独谜题问题
  • 2、设计在链式存储结构上交换二叉树中所有结点左右子树的算法。
  • MySQL进阶部分