geojson文件默认已有的style会导致webGL渲染错误处理办法

geojson文件默认已有的style会导致webGL渲染错误处理办法

相关链接:

功能示例(Vue版) | Mars3D三维可视化平台 | 火星科技

代码:

复制代码
export function showDraw(isFlyTo) {
  removeLayer()

  graphicLayer = new mars3d.layer.GeoJsonLayer({
    data: {
      type: "FeatureCollection",
      features: [
        {
          type: "Feature",
          geometry: {
            type: "Point",
            coordinates: [121.453893, 29.888391],
          },
          properties: {
            gid: "1",
            code: "1718850737365",
            type: 'circleP',
            style: {
              radius: 1693.63
            }
          },
          id: "fid--45368680_1902ac1ce0f_-7fde",
        },
      ],
    },
    symbol: {
      styleOptions: {
        color: "#FF0000",
      },
    },
    flyTo: true
  });
  map.addLayer(graphicLayer);
}

效果:

报错:

Cesium.js:15236 An error occurred while rendering. Rendering has stopped.

DeveloperError: normalized result is not a number

Error

处理办法:

设置下 merge为true即可,

正确代码:

复制代码
export function showDraw(isFlyTo) {
  removeLayer()

  graphicLayer = new mars3d.layer.GeoJsonLayer({
    data: {
      type: "FeatureCollection",
      features: [
        {
          type: "Feature",
          geometry: {
            type: "Point",
            coordinates: [121.453893, 29.888391],
          },
          properties: {
            gid: "1",
            code: "1718850737365",
            type: 'circleP',
            style: {
              radius: 1693.63
            }
          },
          id: "fid--45368680_1902ac1ce0f_-7fde",
        },
      ],
    },
    symbol: {
      merge: true,
      styleOptions: {
        color: "#FF0000",
      },
    },
    flyTo: true
  });
  map.addLayer(graphicLayer);
}

正常效果:

原因:

1.内置的style与symbol配置冲突,需要合并并覆盖json中已有的style

相关api:

Mars3D三维可视化平台 | 火星科技

相关推荐
无限压榨切图仔18 分钟前
从 Claude Code 切到 Codex:我用 Agent、Skills、MCP 做完了一个内容运营工具
前端·后端
濮水大叔21 分钟前
NestJS 与 CabloyJS 的 env/config 架构对比:从环境变量到实例级配置
前端·node.js·nestjs
成都渲染101云渲染666622 分钟前
Blender渲染时,纯CPU渲染的设置教程
前端·javascript·blender
董员外25 分钟前
RAG 系统进化论(一):纵览 RAG 的发展历程
前端·人工智能·后端
多加点辣也没关系44 分钟前
JavaScript|第30章:事件机制
开发语言·javascript
Gauss松鼠会1 小时前
【GaussDB】GaussDB锁阻塞源头查询
java·开发语言·前端·数据库·算法·gaussdb·经验总结
YHHLAI1 小时前
Vue 3 流式输出实战:从零掌握 LLM Streaming 与 SSE 协议
前端·javascript·vue.js
2601_965798472 小时前
Arrow Unlocker HTML5 Game Review: Keep Web Arcade Players Coming Back
前端·html·html5
不简说2 小时前
JS 代码技巧 vol.10 — 20 个 V8 引擎原理,解释"为什么这样写快"
前端·javascript·面试
醉城夜风~2 小时前
HTML常用标签详解学习博客:从基础标签到页面结构完整掌握
前端·学习·html