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三维可视化平台 | 火星科技

相关推荐
excel19 分钟前
Three.js 材质(Material)详解 —— 区别、原理、场景与示例
前端
掘金安东尼40 分钟前
抛弃自定义模态框:原生Dialog的实力
前端·javascript·github
hj5914_前端新手4 小时前
javascript基础- 函数中 this 指向、call、apply、bind
前端·javascript
薛定谔的算法4 小时前
低代码编辑器项目设计与实现:以JSON为核心的数据驱动架构
前端·react.js·前端框架
Hilaku5 小时前
都2025年了,我们还有必要为了兼容性,去写那么多polyfill吗?
前端·javascript·css
yangcode5 小时前
iOS 苹果内购 Storekit 2
前端
LuckySusu5 小时前
【js篇】JavaScript 原型修改 vs 重写:深入理解 constructor的指向问题
前端·javascript
LuckySusu5 小时前
【js篇】如何准确获取对象自身的属性?hasOwnProperty深度解析
前端·javascript
刘皇叔code5 小时前
如何给Three.js中ExtrudeGeometry的不同面设置不同材质
webgl·three.js
LuckySusu5 小时前
【js篇】深入理解 JavaScript 作用域与作用域链
前端·javascript