登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
AI 队友
登录
注册
轻量养虾,开箱即用!低 Token + 稳定算力,Gitee & 模力方舟联合出品的 PocketClaw 正式开售!点击了解详情~
代码拉取完成,页面将自动刷新
开源项目
>
企业应用
>
GIS/地图/导航/定位
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
119
Star
1.2K
Fork
301
火星科技
/
Mars3D三维可视化平台
代码
Issues
0
Pull Requests
0
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
开发画像分析
我知道了,不再自动展开
更新失败,请稍后重试!
移除标识
内容风险标识
本任务被
标识为内容中包含有代码安全 Bug 、隐私泄露等敏感信息,仓库外成员不可访问
使用这个行政区并且调整亮度之后导致背景图无法显示
已关闭
#I9VRHT
需求
yangconghui123
创建于
2024-06-06 17:27
``` import * as mars3d from "mars3d" export let map let graphicLayer let terrainClip // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并) export const mapOptions = { scene: { center: { lat: 30.773023, lng: 116.473055, alt: 133111.3, heading: 40.4, pitch: -47.9 }, orderIndependentTranslucency: false, backgroundImage: "url(/img/tietu/backGroundImg.jpg)", showMoon: false, showSkyBox: false, showSkyAtmosphere: false, fog: false, globe: { baseColor: "rgba(0,0,0,0)", showGroundAtmosphere: false, enableLighting: false } }, control: { baseLayerPicker: true }, terrain: { show: false } } /** * 初始化地图业务,生命周期钩子函数(必须) * 框架在地图初始化完成后自动调用该函数 * @param {mars3d.Map} mapInstance 地图对象 * @returns {void} 无 */ export function onMounted(mapInstance) { map = mapInstance // 记录map map.basemap = 2017 //修改地图亮度 let brightnessEffect = new mars3d.effect.BrightnessEffect() brightnessEffect.brightness=1.8; map.addEffect(brightnessEffect) // 添加矢量图层 graphicLayer = new mars3d.layer.GraphicLayer() map.addLayer(graphicLayer) // graphicLayer 图层下的所有矢量数据都会触发该事件 graphicLayer.on(mars3d.EventType.click, (event) => { const attr = event.graphic?.attr if (attr) { globalMsg(attr.name + ":" + attr.adcode) } }) // map.scene.debugShowFramesPerSecond = true terrainClip = new mars3d.thing.TerrainClip({ image: false, splitNum: 80 // 井边界插值数 }) map.addThing(terrainClip) mars3d.Util.fetchJson({ url: "http://data.mars3d.cn/file/geojson/areas/340100.json" }) .then(function (geojson) { const arr = mars3d.Util.geoJsonToGraphics(geojson) // 解析geojson const options = arr[0] terrainClip.addArea(options.positions, { simplify: { tolerance: 0.002 } }) terrainClip.clipOutSide = true const polylineGraphic = new mars3d.graphic.PolylineEntity({ positions: options.positions, style: { width: 10, color: "#b3e0ff", depthFail: false, materialType: mars3d.MaterialType.PolylineGlow, materialOptions: { color: "#b3e0ff", glowPower: 0.3, taperPower: 1.0 } } }) graphicLayer.addGraphic(polylineGraphic) const wall = new mars3d.graphic.WallPrimitive({ positions: options.positions, style: { setHeight: -20000, diffHeight: 20000, // 墙高 width: 10, materialType: mars3d.MaterialType.Image2, materialOptions: { image: "./img/textures/fence-top.png", color: "#0b88e3" } } }) graphicLayer.addGraphic(wall) }) .catch(function (error) { console.log("加载JSON出错", error) }) mars3d.Util.fetchJson({ url: "http://data.mars3d.cn/file/geojson/areas/340100_full.json" }).then(function (geojson) { const arr = mars3d.Util.geoJsonToGraphics(geojson) // 解析geojson for (let i = 0; i < arr.length; i++) { const item = arr[i] const attr = item.attr // 属性信息 const graphic = new mars3d.graphic.PolylinePrimitive({ positions: item.positions, style: { color: "rgba(255,255,255,0.3)", depthFail: true, width: 2 }, attr }) graphicLayer.addGraphic(graphic) addCenterGraphi(attr) } }) } /** * 释放当前地图业务的生命周期函数 * @returns {void} 无 */ export function onUnmounted() { map = null } function addCenterGraphi(attr) { const circleGraphic = new mars3d.graphic.CircleEntity({ position: new mars3d.LngLatPoint(attr.centroid[0], attr.centroid[1], 100), style: { radius: 5000, materialType: mars3d.MaterialType.CircleWave, materialOptions: { color: "#0b88e3", count: 2, speed: 10 } }, attr }) graphicLayer.addGraphic(circleGraphic) const divGraphic = new mars3d.graphic.DivGraphic({ position: attr.centroid, style: { html: `<div class="mars-four-color mars3d-animation"> <img src="${getImage()}" class="four-color_bg"></img> <div class="four-color_name">${attr.name}</div> </div>`, horizontalOrigin: Cesium.HorizontalOrigin.LEFT, verticalOrigin: Cesium.VerticalOrigin.CENTER, clampToGround: true }, attr }) graphicLayer.addGraphic(divGraphic) } // 简化geojson的坐标 function simplifyGeoJSON(geojson) { try { geojson = turf.simplify(geojson, { tolerance: 0.009, highQuality: true, mutate: true }) } catch (e) { // } return geojson } // 根据随机数字取图片 function getImage() { const num = Math.floor(Math.random() * 5) switch (num) { case 1: return "/img/icon/map-title-y.png" case 2: return "/img/icon/map-title-h.png" case 3: return "/img/icon/map-title-o.png" case 4: return "/img/icon/map-title-r.png" default: return "/img/icon/map-title-b.png" } } ```
``` import * as mars3d from "mars3d" export let map let graphicLayer let terrainClip // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并) export const mapOptions = { scene: { center: { lat: 30.773023, lng: 116.473055, alt: 133111.3, heading: 40.4, pitch: -47.9 }, orderIndependentTranslucency: false, backgroundImage: "url(/img/tietu/backGroundImg.jpg)", showMoon: false, showSkyBox: false, showSkyAtmosphere: false, fog: false, globe: { baseColor: "rgba(0,0,0,0)", showGroundAtmosphere: false, enableLighting: false } }, control: { baseLayerPicker: true }, terrain: { show: false } } /** * 初始化地图业务,生命周期钩子函数(必须) * 框架在地图初始化完成后自动调用该函数 * @param {mars3d.Map} mapInstance 地图对象 * @returns {void} 无 */ export function onMounted(mapInstance) { map = mapInstance // 记录map map.basemap = 2017 //修改地图亮度 let brightnessEffect = new mars3d.effect.BrightnessEffect() brightnessEffect.brightness=1.8; map.addEffect(brightnessEffect) // 添加矢量图层 graphicLayer = new mars3d.layer.GraphicLayer() map.addLayer(graphicLayer) // graphicLayer 图层下的所有矢量数据都会触发该事件 graphicLayer.on(mars3d.EventType.click, (event) => { const attr = event.graphic?.attr if (attr) { globalMsg(attr.name + ":" + attr.adcode) } }) // map.scene.debugShowFramesPerSecond = true terrainClip = new mars3d.thing.TerrainClip({ image: false, splitNum: 80 // 井边界插值数 }) map.addThing(terrainClip) mars3d.Util.fetchJson({ url: "http://data.mars3d.cn/file/geojson/areas/340100.json" }) .then(function (geojson) { const arr = mars3d.Util.geoJsonToGraphics(geojson) // 解析geojson const options = arr[0] terrainClip.addArea(options.positions, { simplify: { tolerance: 0.002 } }) terrainClip.clipOutSide = true const polylineGraphic = new mars3d.graphic.PolylineEntity({ positions: options.positions, style: { width: 10, color: "#b3e0ff", depthFail: false, materialType: mars3d.MaterialType.PolylineGlow, materialOptions: { color: "#b3e0ff", glowPower: 0.3, taperPower: 1.0 } } }) graphicLayer.addGraphic(polylineGraphic) const wall = new mars3d.graphic.WallPrimitive({ positions: options.positions, style: { setHeight: -20000, diffHeight: 20000, // 墙高 width: 10, materialType: mars3d.MaterialType.Image2, materialOptions: { image: "./img/textures/fence-top.png", color: "#0b88e3" } } }) graphicLayer.addGraphic(wall) }) .catch(function (error) { console.log("加载JSON出错", error) }) mars3d.Util.fetchJson({ url: "http://data.mars3d.cn/file/geojson/areas/340100_full.json" }).then(function (geojson) { const arr = mars3d.Util.geoJsonToGraphics(geojson) // 解析geojson for (let i = 0; i < arr.length; i++) { const item = arr[i] const attr = item.attr // 属性信息 const graphic = new mars3d.graphic.PolylinePrimitive({ positions: item.positions, style: { color: "rgba(255,255,255,0.3)", depthFail: true, width: 2 }, attr }) graphicLayer.addGraphic(graphic) addCenterGraphi(attr) } }) } /** * 释放当前地图业务的生命周期函数 * @returns {void} 无 */ export function onUnmounted() { map = null } function addCenterGraphi(attr) { const circleGraphic = new mars3d.graphic.CircleEntity({ position: new mars3d.LngLatPoint(attr.centroid[0], attr.centroid[1], 100), style: { radius: 5000, materialType: mars3d.MaterialType.CircleWave, materialOptions: { color: "#0b88e3", count: 2, speed: 10 } }, attr }) graphicLayer.addGraphic(circleGraphic) const divGraphic = new mars3d.graphic.DivGraphic({ position: attr.centroid, style: { html: `<div class="mars-four-color mars3d-animation"> <img src="${getImage()}" class="four-color_bg"></img> <div class="four-color_name">${attr.name}</div> </div>`, horizontalOrigin: Cesium.HorizontalOrigin.LEFT, verticalOrigin: Cesium.VerticalOrigin.CENTER, clampToGround: true }, attr }) graphicLayer.addGraphic(divGraphic) } // 简化geojson的坐标 function simplifyGeoJSON(geojson) { try { geojson = turf.simplify(geojson, { tolerance: 0.009, highQuality: true, mutate: true }) } catch (e) { // } return geojson } // 根据随机数字取图片 function getImage() { const num = Math.floor(Math.random() * 5) switch (num) { case 1: return "/img/icon/map-title-y.png" case 2: return "/img/icon/map-title-h.png" case 3: return "/img/icon/map-title-o.png" case 4: return "/img/icon/map-title-r.png" default: return "/img/icon/map-title-b.png" } } ```
评论 (
2
)
登录
后才可以发表评论
状态
已关闭
新建
等待沟通
已解决
处理中
延期处理
已关闭
负责人
未设置
棉棉
mianmianwu96
负责人
协作者
+负责人
+协作者
标签
未设置
项目
未立项任务
未立项任务
里程碑
未关联里程碑
未关联里程碑
Pull Requests
未关联
未关联
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
未关联
分支 (
-
)
标签 (
-
)
开始日期   -   截止日期
-
置顶选项
不置顶
置顶等级:高
置顶等级:中
置顶等级:低
优先级
不指定
严重
主要
次要
不重要
预计工期
(小时)
参与者(3)
JavaScript
1
https://gitee.com/marsgis/mars3d.git
git@gitee.com:marsgis/mars3d.git
marsgis
mars3d
Mars3D三维可视化平台
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册