🐄 获取三维视角
JSON.stringify({
destination: gismap.util.viewer.camera.position,
orientation: {
direction: gismap.util.viewer.camera.direction,
up: gismap.util.viewer.camera.up,
heading: gismap.util.viewer.camera.heading,
pitch: gismap.util.viewer.camera.pitch,
roll: gismap.util.viewer.camera.roll,
}
})
🐄 打开工具栏
// 打开工具栏
emitter.emit("activeTool", name);
🐄 切换实景图
// 不要用
mapUtil.changeMapType("2d" || "3d" ); 这个不是很靠谱,深度监听不会打开。
// 建议使用
window.$changeBaseMap("实景图", "一级图 ( 地形级 )");
🐄 查看图层相关信息并叠加图层
// 叠加图层
window.postMessage(
{
key: "$CesiumLayersManager",
func: "addLayersById",
params: [
catologId,
false,
[
{
serviceId: serviceId,
layers: ["0.0", "0.1"],,
layerDefs: [],
},
],
],
},
"*"
);
1.查看图层的目录id

2.查看图层的serviceid

3.查看图层的图层号


🐄 直接永CesiumLayersManager实例 清空所有图层
// 清空所有图层
$CesiumLayersManager.getInstance().removeALLLayers();
🐄 叠加图层带图层过滤参数
// 清空所有图层
window.postMessage(
{
key: "$CesiumLayersManager",
func: "removeALLLayers",
params: [],
},
"*"
);
const catologId = row.layer;
console.log(catologId, "catologId");
// 叠图
window.postMessage(
{
key: "$CesiumLayersManager",
func: "addLayersById",
params: [
catologId.id,
,
false,
[
{
serviceId: catologId.serviceId,
layers: [...catologId.layers],
layerDefs: [...catologId.layerDefs],
},
],
],
},
"*"
);
🐄 先叠加图层再图层过滤
// 1.先叠加图层
const layers = mapUtil.util.loadedLayers.items;
const isExist = layers.find((layer) => layer.id === row.layer.id);
if (!isExist) {
// 叠加图层
const catologId = row.layer;
$CesiumLayersManager
.getInstance()
.addLayersById(catologId.id)
.then(() => {
// 再过滤
filterLayerByExpression(row);
});
} else {
filterLayerByExpression(row);
}
function filterLayerByExpression(row) {
mapUtil.util.filterLayerByExpression([
{
catalogId: row.layer.id,
services: [
{
serviceId: row.layer.serviceId,
layers: row.layer.layerDefs,
},
],
},
]);
}
🐄 叠加图层带token
mapUtil.util.loadLayers(catalog, { headers: { Authorization: getToken() } })
🐄 postMessage叠加图层和支持自定义地图方法
// 叠加图层-单个
window.postMessage(
{
key: '$CesiumLayersManager',
func: 'addLayersById',
params: ['dd9e1810-e4ca-493d-b900-22e119e7b2c4']
},
'*'
)
// 叠加图层-多个
window.postMessage(
{
key: '$CesiumLayersManager',
func: 'addLayersByIds',
params: [['dd9e1810-e4ca-493d-b900-22e119e7b2c4', 'ece4bb1c-ce54-434d-80a7-e843c9e0ec59']]
},
'*'
)
// 清空-单个
window.postMessage(
{
key: '$CesiumLayersManager',
func: 'removeLayersById',
params: ['dd9e1810-e4ca-493d-b900-22e119e7b2c4']
},
'*'
)
// 清空-多个
window.postMessage(
{
key: '$CesiumLayersManager',
func: 'removeLayersByIds',
params: [['dd9e1810-e4ca-493d-b900-22e119e7b2c4', 'ece4bb1c-ce54-434d-80a7-e843c9e0ec59']]
},
'*'
)
// 清空全部图层
window.postMessage({ key: '$CesiumLayersManager', func: 'removeALLLayers', params: [] }, '*')
// 设置视角
window.postMessage(
{
key: 'customFunction',
func: `({mapUtil}) => {
mapUtil.util.setMapExtent([
102.68151997958313,
27.58566306727317,
112.71940162447768,
32.77320893297453
])
}`
},
'*'
)
🐄 区县定位
// 根据areaCode定位
const locateByAreaCode = async (
areaCode: string,
withMaskLayer: boolean = false,
locateOption?: ILocate
) => {
if (areaCode === '500112') {
// 渝北区范围
await locate({
url: window.$config.regionLayerUrl,
where: 'QXMC=\'渝北区\'',
clear: false
}).then((features) => {
withMaskLayer && addMaskLayer(features)
})
return
}
let url = window.$config.areaLayerUrl + '/8'
let where = `行政区代码_X='${areaCode}'`
if (areaCode === '500141' || areaCode === '500157') { // 两江新区新老code
url = 'http://23.36.250.69/datamanager/service/7f700737-e168-419c-a142-af17aa168a1e/a130f037-da1f-48d4-8ec8-9a3714dd9600/f4255a31-0bf7-43d8-9931-0b1172b447f8/MapServer/3'
where = ''
}
const features = await locate({ url, where, ...locateOption })
if (features && withMaskLayer) {
addMaskLayer(features)
}
}
import useLocate from '@/hooks/useLocate'
const { locateByAreaCode } = useLocate()
locateByAreaCode(area.areaid, false, { highlight: true })
🐄 设置视角
// 设置视角
mapUtil.util.setMapExtent()
//或者固定视角
mapUtil.util.setMapExtent([
100.36988168663606, 26.871804812178127, 115.18586671620167, 34.164047443917454
])
🐄 清空高亮
mapUtil.util.clearHighlight()
🐄 获取叠加的图层
mapUtil.util.loadedLayers
🐄 地图类型枚举,叠加图层
getShareUrl(item, appId) {
const baseURL = 'api/shData'
let url = ''
if (item) {
const type = item.dataShareType
const type2 = item.resourcetype
const id = item.id
const serviceType = item.serviceType
const fileid = item.fileid
if (type === 'service') {
if (serviceType === 'FeatureServer') {
url = `${baseURL}/share/service/${appId}/${id}/FeatureServer?f=json`
} else if (serviceType === 'ImageServer') {
url = `${baseURL}/share/service/${appId}/${id}/ImageServer?f=json`
} else if (serviceType === 'ArcGISTileService') {
url = `${baseURL}/share/service/${appId}/${id}/MapServer?f=json`
} else if (serviceType === 'VectorTileServer') {
url = `${baseURL}/share/service/${appId}/${id}/VectorTileServer?f=json`
} else if (serviceType === 'OGCWMTS') {
url = `${baseURL}/share/service/${appId}/${id}/wmts`
} else if (serviceType === 'OGCWMS') {
url = `${baseURL}/share/service/${appId}/${id}/wms`
} else if (serviceType === 'OGCWFS') {
url = `${baseURL}/${id}/wfs?request=GetCapabilities&service=WFS`
} else if (serviceType === 'webservice') {
url = `${baseURL}/share/service/${appId}/${id}/webservice`
} else if (serviceType === 'SceneServer') {
// SceneServer
url = `${baseURL}/share/service/${appId}/rest/services/Hosted/${id}/SceneServer`
} else if (serviceType === 'PointCloudLayer') {
// PointCloudLayer
url = `${baseURL}/share/service/${appId}/rest/services/Hosted/${id}/SceneServer`
} else if (serviceType === 'IntegratedMeshLayer') {
// IntegratedMeshLayer
url = `${baseURL}/share/service/${appId}/rest/services/Hosted/${id}/SceneServer`
} else if (serviceType === 'BuildingSceneLayer') {
// BuildingSceneLayer
url = `${baseURL}/share/service/${appId}/rest/services/Hosted/${id}/SceneServer`
} else {
url = `${baseURL}/share/service/${appId}/${id}/MapServer?f=json`
}
if (type2 === 'database') {
url = `${baseURL}/share/service/${appId}/db/${id}`
}
} else if (type === 'file') {
if (fileid) {
// url = `${imageBaseUrl}${fileid}`
url = ``
}
url = `${baseURL}/share/service/${appId}/file/${id}`
}
}
if (url.indexOf('http') < 0) {
url = `${location.origin}/${url}`
// url = `http://23.36.250.116:8044/${url}`
}
return url
},
🐄 打开3d或者2d
mapUtil.changeMapType("3d");
mapUtil.changeMapType("2d");
🐄 图层定位中心点
setTimeout(() => {
mapUtil.util.zoomToLayerExtent("ffd28871-16f9-4df5-acd9-1f86862e9e59");
}, 1000);
🐄 arcgis毛总最新地图底座获取视角
1拖动位置,打开控制台
2.mapUtil.util.getMapExtent()
3.复制object
🐄 arcgis取地图的定位坐标
1拖动位置,打开控制台
2. 输入命令 map.regionLayer.view.extent
3.复制object
:::details
:::
🐄 cesuim 地图视角位置
(1) 地图选好视角后,打开浏览器, 在浏览器控制台运行回车
(2) 获取那个视角脚本代码
{position :$viewer.camera.position,up:$viewer.camera.up,heading:$viewer.camera.heading,pitch:$viewer.camera.pitch,roll:$viewer.camera.roll,direction:$viewer.camera.direction}
(3) 获取到数据 定义变量
const camera = {
"position": {
"x": -1585101.2595351234,
"y": 5320992.392833537,
"z": 3130477.613761266
},
"up": {
"x": -0.1643710147599397,
"y": 0.9677301027921298,
"z": 0.19099899909874302
},
"heading": 3.50224042963928,
"pitch": -0.3432502762666627,
"roll": 6.283177516957298,
"direction": {
"x": 0.27784807743680634,
"y": 0.23121586737611863,
"z": -0.9323838632978263
}
}
// 视角定位
viewer.camera.flyTo(
{
destination: new Cartesian3(...camera.position),
orientation: {
direction: new Cartesian3(...camera.direction),
up: new Cartesian3(...camera.up),
heading: camera.heading,
pitch: camera.pitch,
roll: camera.roll,
}
}
)
🐄 页面编辑器 加载蒙版
function() {
planMap.mapComponents[0].view.zoom = 7
setTimeout(() => {
try {
window.planMap.addEsriLayerToMap(planMap.createEsriLayer(planMap.getLayerObjByCatalogIdAndLayerId('95a13841-b21e-4d75-8db3-8ac89a35a59d', 'bcdcd7d9-2b50-450e-9752-f8cc09f6d581')[0]))
window.planMap.addEsriLayerToMap(planMap.createEsriLayer(planMap.getLayerObjByCatalogIdAndLayerId('95a13841-b21e-4d75-8db3-8ac89a35a59d', '388df312-d559-44d6-92c1-304f724a9248')[0]))
const resource = window.planMap.serviceStore.query({ id: '6f2b0169-3512-4931-aa2c-7f3c325ceb54' })[0]
resource.checked = true
window.planMap.setLayerSwitch(true, resource)
} catch (e) { console.error(e) }
try {
const userInfo = JSON.parse(localStorage.userInfo)
const org = userInfo.orgFullName.split('-')
// planMap.locateByAreaname(org[1], true)
mengban(org[1])
} catch (e) { console.error(e) }
}, 500)
console.log('test123')
// 区县定位和蒙版
function mengban(name) {
// const url = 'http://23.36.123.160:10000/multApp/datamanager/service/ad1feab5-2cde-4885-95ea-670725591bee/cfd30e93-ece5-48c1-aacf-509ee2a3dc29/33d8f0c2-5e4c-41cb-9742-4b25cb994446/MapServer/0'
const url = 'http://10.10.6.211/cqgtorg_xxzxadmin_site04/rest/services/%E5%B9%B3%E5%8F%B0/syfztc/FeatureServer/8'
const mapComponent = planMap.mapComponents[0]
planMap.createEsriQueryTask(url, {
where: `管理区名称 like '%${name}%'`,
returnGeometry: true
}).then(({ features }) => {
if (!features.length) return
// 区县定位
planMap.mapComponents[0].view.goTo(features)
const maskLayer = new window.Esri.GraphicsLayer({
id: `mask-layer`,
listMode: 'hide',
title: '蒙版图层'
})
mapComponent.map.add(maskLayer)
const extent = new window.Esri.Polygon({
spatialReference:
mapComponent.view.spatialReference,
rings: [
[
[-180, -90],
[180, -90],
[180, 90],
[-180, 90]
]
]
})
const geos = features.map((item) => item.geometry)
const geo =
geos.length > 1 ? window.Esri.geometryEngine.union(geos) : geos[0]
if (geo) {
//高亮定位
planMap.highlightByGeometrys([geo], true, true)
const geometry = window.Esri.geometryEngine.difference(extent, geo)
const gra = new window.Esri.Graphic({
geometry: geometry,
symbol: {
type: 'simple-fill',
color: '#0b1b49',
outline: {
color: '#0b1b49'
}
}
})
maskLayer.graphics.add(gra)
}
})
mapComponent.map.layers.on('after-add', e => {
const maskLayer = mapComponent.map.findLayerById(`mask-layer`)
if (maskLayer && e.item && e.item.id !== `mask-layer`) {
// 计算排序号
let order = mapComponent.map.layers.items.length - 1
// 如果包含标记图层 则再减1
if (mapComponent.map.layers.items.filter(ly => ly.id.indexOf('markerLayer_') !== -1).length > 0) {
order = order - 1
}
mapComponent.map.layers.reorder(maskLayer, order)
}
})
}
}

509

被折叠的 条评论
为什么被折叠?



