Commit 4a19b66c by wanghao

同步代码

parent cb3e1012
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
"fog": true, "fog": true,
"fxaa": true, "fxaa": true,
"requestRenderMode": false, "requestRenderMode": false,
"contextOptions": {
"requestWebgl1": false
},
"globe": { "globe": {
"depthTestAgainstTerrain": false, "depthTestAgainstTerrain": false,
"baseColor": "#546a53", "baseColor": "#546a53",
......
...@@ -87,6 +87,11 @@ ...@@ -87,6 +87,11 @@
"main": "map/options/control" "main": "map/options/control"
}, },
{ {
"name": "chinaCRS 国内偏移坐标系",
"thumbnail": "map-options-chinaCRS.jpg",
"main": "map/options/chinaCRS"
},
{
"name": "多语言支持", "name": "多语言支持",
"thumbnail": "map-options-lang.jpg", "thumbnail": "map-options-lang.jpg",
"main": "map/options/lang", "main": "map/options/lang",
......
/** /**
* Mars3D三维可视化平台 mars3d * Mars3D三维可视化平台 mars3d
* *
* 版本信息:v3.6.9 * 版本信息:v3.6.10
* 编译日期:2023-10-17 12:43:40 * 编译日期:2023-10-23 17:27:40
* 版权所有:Copyright by 火星科技 http://mars3d.cn * 版权所有:Copyright by 火星科技 http://mars3d.cn
* 使用单位:免费公开版 ,2023-03-17 * 使用单位:免费公开版 ,2023-03-17
*/ */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
import * as mars3d from "mars3d" import * as mars3d from "mars3d"
export let map // mars3d.Map三维地图对象 export let map // mars3d.Map三维地图对象
let mapSplit
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并) // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = { export const mapOptions = {
...@@ -20,9 +21,32 @@ export const mapOptions = { ...@@ -20,9 +21,32 @@ export const mapOptions = {
*/ */
export function onMounted(mapInstance) { export function onMounted(mapInstance) {
map = mapInstance // 记录map map = mapInstance // 记录map
map.basemap = null
const mapSplit = new mars3d.control.MapSplit({ createControl()
// 加载模型图层 [也支持setLayerSplitDirection方法来设置图层]
// const tiles3dLayer = new mars3d.layer.TilesetLayer({
// url: "//data.mars3d.cn/3dtiles/qx-dyt/tileset.json",
// position: { alt: -27 }
// })
// map.addLayer(tiles3dLayer)
// mapSplit.setLayerSplitDirection(tiles3dLayer, Cesium.SplitDirection.RIGHT) // 对模型分屏卷帘
}
/**
* 释放当前地图业务的生命周期函数
* @returns {void} 无
*/
export function onUnmounted() {
map = null
}
export function createControl() {
if (mapSplit) {
return
}
map.basemap = null
mapSplit = new mars3d.control.MapSplit({
rightLayer: [ rightLayer: [
{ name: "天地图卫星", type: "tdt", layer: "img_d" }, { name: "天地图卫星", type: "tdt", layer: "img_d" },
{ {
...@@ -63,20 +87,12 @@ export function onMounted(mapInstance) { ...@@ -63,20 +87,12 @@ export function onMounted(mapInstance) {
` `
const splitter = mars3d.DomUtil.parseDom(addHTML, true) const splitter = mars3d.DomUtil.parseDom(addHTML, true)
mapSplit.container.appendChild(splitter) mapSplit.container.appendChild(splitter)
// 加载模型图层 [也支持setLayerSplitDirection方法来设置图层]
// const tiles3dLayer = new mars3d.layer.TilesetLayer({
// url: "//data.mars3d.cn/3dtiles/qx-dyt/tileset.json",
// position: { alt: -27 }
// })
// map.addLayer(tiles3dLayer)
// mapSplit.setLayerSplitDirection(tiles3dLayer, Cesium.SplitDirection.RIGHT) // 对模型分屏卷帘
} }
/** export function destroyControl() {
* 释放当前地图业务的生命周期函数 if (mapSplit) {
* @returns {void} 无 map.removeControl(mapSplit)
*/ mapSplit = null
export function onUnmounted() { map.basemap = "ArcGIS影像"
map = null }
} }
...@@ -308,6 +308,7 @@ function throttled(fn, delay) { ...@@ -308,6 +308,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -271,6 +271,7 @@ function throttled(fn, delay) { ...@@ -271,6 +271,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -172,6 +172,7 @@ function throttled(fn, delay) { ...@@ -172,6 +172,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -213,6 +213,7 @@ function throttled(fn, delay) { ...@@ -213,6 +213,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -193,6 +193,7 @@ function throttled(fn, delay) { ...@@ -193,6 +193,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -114,6 +114,7 @@ function throttled(fn, delay) { ...@@ -114,6 +114,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -186,6 +186,7 @@ function throttled(fn, delay) { ...@@ -186,6 +186,7 @@ function throttled(fn, delay) {
const remaining = delay - (curTime - starttime) const remaining = delay - (curTime - starttime)
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const context = this const context = this
// eslint-disable-next-line prefer-rest-params
const args = arguments const args = arguments
clearTimeout(timer) clearTimeout(timer)
if (remaining <= 0) { if (remaining <= 0) {
......
...@@ -44,6 +44,7 @@ export function onMounted(mapInstance) { ...@@ -44,6 +44,7 @@ export function onMounted(mapInstance) {
// addDemoGraphic9(graphicLayer) // addDemoGraphic9(graphicLayer)
addDemoGraphic10(graphicLayer) addDemoGraphic10(graphicLayer)
addDemoGraphic11(graphicLayer) addDemoGraphic11(graphicLayer)
addDemoGraphic12(graphicLayer)
} }
/** /**
...@@ -376,11 +377,17 @@ function addDemoGraphic10(graphicLayer) { ...@@ -376,11 +377,17 @@ function addDemoGraphic10(graphicLayer) {
radius: 500, radius: 500,
opacity: 0.4, opacity: 0.4,
color: "#02D4FD", color: "#02D4FD",
outline: false, clampToGround: true,
outlineColor: "#8A99B4",
outlineWidth: 2, outline: true,
outlineOpacity: 1, outlineStyle: {
clampToGround: true width: 12,
materialType: mars3d.MaterialType.Image2,
materialOptions: {
image: "/img/textures/airline.svg",
repeat: new mars3d.Cesium.Cartesian2(1000, 1)
}
}
}, },
attr: { remark: "示例10" } attr: { remark: "示例10" }
}) })
...@@ -427,6 +434,28 @@ function addDemoGraphic11(graphicLayer) { ...@@ -427,6 +434,28 @@ function addDemoGraphic11(graphicLayer) {
graphicLayer.addGraphic(graphic) graphicLayer.addGraphic(graphic)
} }
function addDemoGraphic12(graphicLayer) {
const graphic = new mars3d.graphic.CircleEntity({
position: new mars3d.LngLatPoint(116.155132, 30.956363, 677.2),
style: {
radius: 1000,
fill: false,
outline: true,
outlineStyle: {
width: 12,
materialType: mars3d.MaterialType.Image2,
materialOptions: {
image: "/img/textures/line-air.svg",
repeat: new mars3d.Cesium.Cartesian2(500, 1)
}
}
},
attr: { remark: "示例12" }
})
graphicLayer.addGraphic(graphic)
}
// 生成演示数据(测试数据量) // 生成演示数据(测试数据量)
export function addRandomGraphicByCount(count) { export function addRandomGraphicByCount(count) {
graphicLayer.clear() graphicLayer.clear()
......
...@@ -5,6 +5,13 @@ export let graphicLayer // 矢量图层对象 ...@@ -5,6 +5,13 @@ export let graphicLayer // 矢量图层对象
export const eventTarget = new mars3d.BaseClass() export const eventTarget = new mars3d.BaseClass()
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = {
scene: {
resolutionScale: 2.0 // 可以提高文字清晰度
}
}
/** /**
* 初始化地图业务,生命周期钩子函数(必须) * 初始化地图业务,生命周期钩子函数(必须)
* 框架在地图初始化完成后自动调用该函数 * 框架在地图初始化完成后自动调用该函数
...@@ -48,8 +55,8 @@ function addDemoGraphic1(graphicLayer) { ...@@ -48,8 +55,8 @@ function addDemoGraphic1(graphicLayer) {
position: new mars3d.LngLatPoint(116.308659, 30.914005, 429.94), position: new mars3d.LngLatPoint(116.308659, 30.914005, 429.94),
style: { style: {
text: "合肥火星科技有限公司", text: "合肥火星科技有限公司",
font_size: 46, font_size: 46, // 字号放大一倍
scale: 0.5, scale: 0.5, // scale传0.5
font_family: "楷体", font_family: "楷体",
color: "#00ffff", color: "#00ffff",
outline: true, outline: true,
...@@ -124,12 +131,9 @@ function addDemoGraphic4(graphicLayer) { ...@@ -124,12 +131,9 @@ function addDemoGraphic4(graphicLayer) {
position: new mars3d.LngLatPoint(116.329102, 30.977955, 1548.6), position: new mars3d.LngLatPoint(116.329102, 30.977955, 1548.6),
style: { style: {
text: "火星科技Mars3D平台", text: "火星科技Mars3D平台",
font_size: 25, font_size: 20,
font_family: "楷体", font_family: "宋体",
color: "#0081c2", color: "#ffffff",
outline: true,
outlineColor: "#ffffff",
outlineWidth: 2,
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 100000), distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 100000),
// 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用 // 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
......
...@@ -151,6 +151,9 @@ function addDemoGraphic2(graphicLayer) { ...@@ -151,6 +151,9 @@ function addDemoGraphic2(graphicLayer) {
const interval = 20 const interval = 20
changePosition(graphic, interval) changePosition(graphic, interval)
setInterval(() => { setInterval(() => {
if (graphic.isDestroy) {
return
}
changePosition(graphic, interval) changePosition(graphic, interval)
}, interval * 1000) }, interval * 1000)
} }
......
...@@ -3,6 +3,13 @@ import * as mars3d from "mars3d" ...@@ -3,6 +3,13 @@ import * as mars3d from "mars3d"
export let map // mars3d.Map三维地图对象 export let map // mars3d.Map三维地图对象
export let graphicLayer // 矢量图层对象 export let graphicLayer // 矢量图层对象
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = {
scene: {
resolutionScale: 2.0 // 可以提高文字清晰度
}
}
/** /**
* 初始化地图业务,生命周期钩子函数(必须) * 初始化地图业务,生命周期钩子函数(必须)
* 框架在地图初始化完成后自动调用该函数 * 框架在地图初始化完成后自动调用该函数
...@@ -121,12 +128,9 @@ function addDemoGraphic4(graphicLayer) { ...@@ -121,12 +128,9 @@ function addDemoGraphic4(graphicLayer) {
position: new mars3d.LngLatPoint(116.329102, 30.977955, 1548.6), position: new mars3d.LngLatPoint(116.329102, 30.977955, 1548.6),
style: { style: {
text: "火星科技Mars3D平台", text: "火星科技Mars3D平台",
font_size: 25, font_size: 20,
font_family: "楷体", font_family: "宋体",
color: "#0081c2", color: "#ffffff",
outline: true,
outlineColor: "#ffffff",
outlineWidth: 2,
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 100000), distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, 100000),
// 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用 // 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
......
...@@ -118,7 +118,7 @@ export function drawClear() { ...@@ -118,7 +118,7 @@ export function drawClear() {
// 清除效果 // 清除效果
export function clearResult() { export function clearResult() {
tableList = [] tableList = []
map.graphicLayer.clear() drawClear()
} }
//= ===============卫星过境=================================== //= ===============卫星过境===================================
...@@ -298,7 +298,6 @@ function showResult(newSatelliteArr) { ...@@ -298,7 +298,6 @@ function showResult(newSatelliteArr) {
globalMsg("分析完成,共" + tableList.length + "条过境记录") globalMsg("分析完成,共" + tableList.length + "条过境记录")
} }
function showCorridor(data) { function showCorridor(data) {
const graphic = new mars3d.graphic.CorridorPrimitive({ const graphic = new mars3d.graphic.CorridorPrimitive({
positions: data.positions, positions: data.positions,
......
...@@ -25,7 +25,11 @@ export function onMounted(mapInstance) { ...@@ -25,7 +25,11 @@ export function onMounted(mapInstance) {
// 天地图 三维地名服务图层 // 天地图 三维地名服务图层
const tdtDmLayer = new mars3d.layer.TdtDmLayer({ const tdtDmLayer = new mars3d.layer.TdtDmLayer({
key: mars3d.Token.tianditu key: mars3d.Token.tianditu,
label: {
pixelOffsetY: -20,
visibleDepth: false
}
}) })
map.addLayer(tdtDmLayer) map.addLayer(tdtDmLayer)
} }
......
...@@ -5,7 +5,6 @@ export let map // mars3d.Map三维地图对象 ...@@ -5,7 +5,6 @@ export let map // mars3d.Map三维地图对象
const creditHtml = `©2023 中科星图- <span>审图号:GS (2023) 1924号</span> const creditHtml = `©2023 中科星图- <span>审图号:GS (2023) 1924号</span>
- 甲测资字11111577 - <a href="https://geovisearth.com/declaration#/user" target="_blank" trace="tos">服务条款</a> ` - 甲测资字11111577 - <a href="https://geovisearth.com/declaration#/user" target="_blank" trace="tos">服务条款</a> `
// 星图官方地址:https://datacloud.geovisearth.com/support/map/summary // 星图官方地址:https://datacloud.geovisearth.com/support/map/summary
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并) // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
...@@ -81,7 +80,8 @@ export function addTileLayer() { ...@@ -81,7 +80,8 @@ export function addTileLayer() {
tileLayer = new mars3d.layer.XyzLayer({ tileLayer = new mars3d.layer.XyzLayer({
name: "地形晕渲", name: "地形晕渲",
url: "https://tiles{s}.geovisearth.com/base/v1/ter/{z}/{x}/{y}?token=82455ef06c72bb3a35bbb4d7d05fd9eceb96a94dc942a056b8feb0e5928ed96f", url: "https://tiles{s}.geovisearth.com/base/v1/ter/{z}/{x}/{y}?token=82455ef06c72bb3a35bbb4d7d05fd9eceb96a94dc942a056b8feb0e5928ed96f",
subdomains: "123" subdomains: "123",
maximumLevel: 9
}) })
map.addLayer(tileLayer) map.addLayer(tileLayer)
} }
...@@ -93,7 +93,6 @@ export function removeTileLayer() { ...@@ -93,7 +93,6 @@ export function removeTileLayer() {
} }
} }
// 在下侧状态栏增加一个额外div展示图层版权信息 // 在下侧状态栏增加一个额外div展示图层版权信息
let creditDOM let creditDOM
function addCreditDOM() { function addCreditDOM() {
......
...@@ -166,7 +166,6 @@ function removeLayer() { ...@@ -166,7 +166,6 @@ function removeLayer() {
} }
} }
/** /**
* 倾斜摄影 县城社区 * 倾斜摄影 县城社区
* *
...@@ -279,43 +278,22 @@ export function showJzwHefeiDemo() { ...@@ -279,43 +278,22 @@ export function showJzwHefeiDemo() {
url: "//data.mars3d.cn/3dtiles/jzw-hefei/tileset.json", url: "//data.mars3d.cn/3dtiles/jzw-hefei/tileset.json",
maximumScreenSpaceError: 1, maximumScreenSpaceError: 1,
// marsJzwStyle: true, // 打开建筑物特效(内置Shader代码) // marsJzwStyle: true, // 打开建筑物特效(内置Shader代码)
marsJzwStyle: ` marsJzwStyle: {
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) { baseHeight: 0.0, // 物体的基础高度,需要修改成一个合适的建筑基础高度
vec4 position = czm_inverseModelView * vec4(fsInput.attributes.positionEC,1); // 位置 heightRange: 280.0, // 高亮的范围 (baseHeight ~ baseHeight + heightRange)
glowRange: 300.0 // 光环的移动范围
// 注意shader中写浮点数是,一定要带小数点,否则会报错,比如0需要写成0.0,1要写成1.0 },
float _baseHeight = 50.0; // 物体的基础高度,需要修改成一个合适的建筑基础高度 style: {
float _heightRange = 380.0; // 高亮的范围(_baseHeight ~ _baseHeight + _heightRange) color: {
float _glowRange = 400.0; // 光环的移动范围(高度) conditions: [["true", "rgba(16, 119, 209, 1)"]]
// 建筑基础色
vec4 diffuse = vec4(0.2, 0.5, 1.0, 1.0); // 固定颜色
//vec4 diffuse = vec4(material.diffuse, material.alpha); // 颜色
float modelHeight = position.z;
if(u_mars3d_jzw_upAxis == 1) {
modelHeight = position.y;
} else if(u_mars3d_jzw_upAxis == 0){
modelHeight = position.x;
} }
},
float mars_height = modelHeight - _baseHeight;
diffuse *= vec4(vec3(mars_height / _heightRange), 1.0); // 渐变
// 动态光环
float time = fract(czm_frameNumber / 360.0);
time = abs(time - 0.5) * 2.0;
float diff = step(0.005, abs( clamp(mars_height / _glowRange, 0.0, 1.0) - time));
material.diffuse = vec3(diffuse.rgb + diffuse.rgb * (1.0 - diff)) ;
}
`,
popup: [ popup: [
{ field: "objectid", name: "编号" }, { field: "objectid", name: "编号" },
{ field: "name", name: "名称" }, { field: "name", name: "名称" },
{ field: "height", name: "楼高", unit: "米" } { field: "height", name: "楼高", unit: "米" }
], ],
center: { lat: 31.795311, lng: 117.206139, alt: 1833, heading: 29, pitch: -26 }, center: { lat: 31.813812, lng: 117.223505, alt: 1047.7, heading: 0, pitch: -39 },
highlight: { highlight: {
type: mars3d.EventType.click, // 单击高亮 type: mars3d.EventType.click, // 单击高亮
outlineEffect: true, // 采用OutlineEffect方式来高亮 outlineEffect: true, // 采用OutlineEffect方式来高亮
......
...@@ -141,6 +141,12 @@ export function setStyle1() { ...@@ -141,6 +141,12 @@ export function setStyle1() {
tiles3dLayer.customShader = undefined tiles3dLayer.customShader = undefined
tiles3dLayer.marsJzwStyle = true // 打开建筑物特效(内置Shader代码) tiles3dLayer.marsJzwStyle = true // 打开建筑物特效(内置Shader代码)
// tiles3dLayer.marsJzwStyle = {
// baseHeight: 0.0, // 物体的基础高度,需要修改成一个合适的建筑基础高度
// heightRange: 280.0, // 高亮的范围 (baseHeight ~ baseHeight + heightRange)
// glowRange: 300.0 // 光环的移动范围
// }
} }
// customShader参数方式 // customShader参数方式
...@@ -218,7 +224,6 @@ export function setStyle3() { ...@@ -218,7 +224,6 @@ export function setStyle3() {
} }
}` }`
}) })
} }
// 颜色改变 // 颜色改变
......
import * as mars3d from "mars3d" import * as mars3d from "mars3d"
export let map // mars3d.Map三维地图对象 export let map // mars3d.Map三维地图对象
let mapEx let mapSplit
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并) // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = { export const mapOptions = {
...@@ -35,6 +35,24 @@ export function onMounted(mapInstance) { ...@@ -35,6 +35,24 @@ export function onMounted(mapInstance) {
// addTestData() // addTestData()
createControl()
// 双击销毁
map.on(mars3d.EventType.dblClick, () => {})
}
/**
* 释放当前地图业务的生命周期函数
* @returns {void} 无
*/
export function onUnmounted() {
map = null
}
export function createControl() {
if (mapSplit) {
return
}
// 修改已有地图为50% // 修改已有地图为50%
const mapOld = document.getElementById("centerDiv3D") const mapOld = document.getElementById("centerDiv3D")
mapOld.style.width = "50%" mapOld.style.width = "50%"
...@@ -55,7 +73,7 @@ export function onMounted(mapInstance) { ...@@ -55,7 +73,7 @@ export function onMounted(mapInstance) {
} }
console.log("分屏地图配置", mars3d.Util.clone(mapOptions2)) console.log("分屏地图配置", mars3d.Util.clone(mapOptions2))
const mapSplit = new mars3d.control.MapCompare({ mapSplit = new mars3d.control.MapCompare({
...mapOptions2, ...mapOptions2,
parentContainer: document.body parentContainer: document.body
}) })
...@@ -65,16 +83,15 @@ export function onMounted(mapInstance) { ...@@ -65,16 +83,15 @@ export function onMounted(mapInstance) {
mapSplit.mapEx.basemap = "天地图电子" mapSplit.mapEx.basemap = "天地图电子"
} }
/** export function destroyControl() {
* 释放当前地图业务的生命周期函数 if (mapSplit) {
* @returns {void} 无 map.removeControl(mapSplit)
*/ mapSplit = null
export function onUnmounted() { const mapOld = document.getElementById("centerDiv3D")
map = null mapOld.style.width = "100%"
}
} }
function addTestData() { function addTestData() {
const groupLayer = new mars3d.layer.GroupLayer({ const groupLayer = new mars3d.layer.GroupLayer({
name: "组图层" name: "组图层"
......
import * as mars3d from "mars3d"
export let map // mars3d.Map三维地图对象
// 默认是无偏坐标系,内部已纠偏,当前示例演示偏移坐标系
// 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
export const mapOptions = {
chinaCRS: mars3d.ChinaCRS.GCJ02, // 标识坐标系
scene: {
center: { lat: 31.833439, lng: 117.212587, alt: 1237, heading: 0, pitch: -60 }
},
basemaps: [
{
name: "天地图影像",
icon: "/img/basemaps/tdt_img.png",
type: "group",
layers: [
{ name: "底图", type: "tdt", layer: "img_d" },
{ name: "注记", type: "tdt", layer: "img_z" }
]
},
{
name: "高德影像",
type: "group",
icon: "/img/basemaps/gaode_img.png",
layers: [
{ name: "底图", type: "gaode", layer: "img_d" },
{ name: "注记", type: "gaode", layer: "img_z" }
],
show: true
}
]
}
/**
* 初始化地图业务,生命周期钩子函数(必须)
* 框架在地图初始化完成后自动调用该函数
* @param {mars3d.Map} mapInstance 地图对象
* @returns {void} 无
*/
export function onMounted(mapInstance) {
map = mapInstance // 记录首次创建的map
map.hasTerrain = false
// 添加参考三维模型
const tiles3dLayer = new mars3d.layer.TilesetLayer({
name: "合肥国家大学科技园",
url: "//data.mars3d.cn/3dtiles/qx-hfdxy/tileset.json",
position: { alt: 0 },
maximumScreenSpaceError: 1,
chinaCRS: mars3d.ChinaCRS.WGS84 // 标识坐标系,自动加偏
})
map.addLayer(tiles3dLayer)
// 增加高德偏移坐标点,进行对比
const graphic = new mars3d.graphic.PointEntity({
position: [117.21343, 31.84052], // 从 https://lbs.amap.com/demo/jsapi-v2/example/geocoder/regeocoding 拾取
style: {
color: "#ff0000",
pixelSize: 10,
outlineColor: "#ffffff",
outlineWidth: 2,
clampToGround: true,
label: {
text: "我是高德偏移坐标的点",
font_size: 18,
color: "#ff0000",
pixelOffsetY: -30,
clampToGround: true
}
},
popup: `我是从 <a href="https://lbs.amap.com/demo/jsapi-v2/example/geocoder/regeocoding" target="_black" >高德官网</a>拾取的高德原始偏移坐标`
})
map.graphicLayer.addGraphic(graphic)
}
/**
* 释放当前地图业务的生命周期函数
* @returns {void} 无
*/
export function onUnmounted() {
map = null
}
...@@ -28,6 +28,51 @@ export const mapOptions = { ...@@ -28,6 +28,51 @@ export const mapOptions = {
"<div>lng:{lng}</div> <div>lat:{lat}</div> <div>alt:{alt} m</div> <div>level:{level}</div><div>heading:{heading}°</div> <div>pitch:{pitch}°</div><div>cameraHeight:{cameraHeight}m</div>" "<div>lng:{lng}</div> <div>lat:{lat}</div> <div>alt:{alt} m</div> <div>level:{level}</div><div>heading:{heading}°</div> <div>pitch:{pitch}°</div><div>cameraHeight:{cameraHeight}m</div>"
} }
}, },
basemaps: [
{
name: "Google Images",
name_cn: "谷歌影像",
name_en: "Google Images",
icon: "/img/basemaps/google_img.png",
type: "google",
layer: "img_d",
show: true
},
{
name: "Tianditu Images",
name_cn: "天地图影像",
name_en: "Tianditu Images",
icon: "/img/basemaps/tdt_img.png",
type: "group",
layers: [
{ name: "底图", type: "tdt", layer: "img_d" },
{ name: "注记", type: "tdt", layer: "img_z" }
],
show: false
},
{
name: "Tianditu Electronic map",
name_cn: "天地图电子",
name_en: "Tianditu Electronic map",
icon: "/img/basemaps/tdt_vec.png",
type: "group",
layers: [
{ name: "底图", type: "tdt", layer: "vec_d" },
{ name: "注记", type: "tdt", layer: "vec_z" }
]
},
{
name: "not map",
name_cn: "无底图",
name_en: "not map",
icon: "/img/basemaps/null.png",
type: "grid",
color: "#ffffff",
alpha: 0.03,
cells: 2
}
],
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
lang: CustomLang // 使用自定义语言配置,配置信息在 ./CustomLang.js lang: CustomLang // 使用自定义语言配置,配置信息在 ./CustomLang.js
} }
...@@ -53,7 +98,9 @@ export function onMounted(mapInstance) { ...@@ -53,7 +98,9 @@ export function onMounted(mapInstance) {
drawLayer.bindContextMenu([ drawLayer.bindContextMenu([
{ {
text: map.getLangText("_删除"), text: () => {
return map.getLangText("_删除")
},
icon: "fa fa-trash-o", icon: "fa fa-trash-o",
show: (event) => { show: (event) => {
const graphic = event.graphic const graphic = event.graphic
...@@ -99,6 +146,10 @@ export function onUnmounted() { ...@@ -99,6 +146,10 @@ export function onUnmounted() {
} }
export function toCustomLang() { export function toCustomLang() {
map.options.basemaps.forEach((item) => {
item.name = item.name_en
})
if (map.controls.locationBar) { if (map.controls.locationBar) {
map.controls.locationBar.options.template = map.controls.locationBar.options.template =
"<div>lng:{lng}</div> <div>lat:{lat}</div> <div>alt:{alt} m</div> <div>level:{level}</div><div>heading:{heading}°</div> <div>pitch:{pitch}°</div><div>cameraHeight:{cameraHeight}m</div><div class='hide700'> {fps} FPS</div>" "<div>lng:{lng}</div> <div>lat:{lat}</div> <div>alt:{alt} m</div> <div>level:{level}</div><div>heading:{heading}°</div> <div>pitch:{pitch}°</div><div>cameraHeight:{cameraHeight}m</div><div class='hide700'> {fps} FPS</div>"
...@@ -109,6 +160,10 @@ export function toCustomLang() { ...@@ -109,6 +160,10 @@ export function toCustomLang() {
} }
export function toDefaultLange() { export function toDefaultLange() {
map.options.basemaps.forEach((item) => {
item.name = item.name_cn
})
if (map.controls.locationBar) { if (map.controls.locationBar) {
map.controls.locationBar.options.template = map.controls.locationBar.options.template =
"<div>经度:{lng}</div> <div>纬度:{lat}</div> <div class='hide1000'>横{crsx} 纵{crsy}</div> <div>海拔:{alt}米</div> <div class='hide700'>层级:{level}</div><div>方向:{heading}°</div> <div>俯仰角:{pitch}°</div><div class='hide700'>视高:{cameraHeight}米</div><div class='hide700'>帧率:{fps} FPS</div>" "<div>经度:{lng}</div> <div>纬度:{lat}</div> <div class='hide1000'>横{crsx} 纵{crsy}</div> <div>海拔:{alt}米</div> <div class='hide700'>层级:{level}</div><div>方向:{heading}°</div> <div>俯仰角:{pitch}°</div><div class='hide700'>视高:{cameraHeight}米</div><div class='hide700'>帧率:{fps} FPS</div>"
......
...@@ -256,11 +256,17 @@ function catmullRom(v, t, alpha = 0.5) { ...@@ -256,11 +256,17 @@ function catmullRom(v, t, alpha = 0.5) {
const type = typeof v const type = typeof v
if (type === "number") { if (type === "number") {
// eslint-disable-next-line prefer-rest-params
p0 = arguments[0] p0 = arguments[0]
// eslint-disable-next-line prefer-rest-params
p1 = arguments[1] p1 = arguments[1]
// eslint-disable-next-line prefer-rest-params
p2 = arguments[2] p2 = arguments[2]
// eslint-disable-next-line prefer-rest-params
p3 = arguments[3] p3 = arguments[3]
// eslint-disable-next-line prefer-rest-params
t = arguments[4] t = arguments[4]
// eslint-disable-next-line prefer-rest-params
alpha = arguments[5] alpha = arguments[5]
} else if (Object.prototype.toString.call(v) === "[object Array]") { } else if (Object.prototype.toString.call(v) === "[object Array]") {
p0 = v[0] p0 = v[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论