电网一张图代码提交
This commit is contained in:
@@ -126,44 +126,60 @@ const LngLat = [
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
import { getAssessOverview } from '@/api/device-boot/panorama'
|
import { getAssessOverview } from '@/api/device-boot/panorama'
|
||||||
|
narimap.publicKey =
|
||||||
|
'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCRYFEiMdZVgY8+jIjx4GR1QbN7qVgCE0istwPZN8xRqdSV+hePUPIW1k9eCVh9gxIIWHAw2TfNZLb8l0Tmk9OH3XnZ009TNBjzZ2zWLrbjFQzgutKKI2JRLK+CaJbOZ0LiD78QnTo5Zk+ZuQBKgtyFJdp4T5gQS+Mnbj/c4EnK0QIDAQAB'
|
||||||
|
narimap.Require(
|
||||||
|
[
|
||||||
|
'PSRMap',
|
||||||
|
'ManageGrid',
|
||||||
|
'Components.Query',
|
||||||
|
'Components.DeviceCard',
|
||||||
|
'Popup',
|
||||||
|
'Components.MapSelector',
|
||||||
|
'Components.RegionSelector',
|
||||||
|
'Marker'
|
||||||
|
],
|
||||||
|
// ['PSRMap', 'Components.Query', 'Marker'],
|
||||||
|
() => {
|
||||||
|
if (narimap.Config.examples.notlogin) {
|
||||||
|
initMap(narimap.Config.styles.sjRaster)
|
||||||
|
} else {
|
||||||
|
//电网GIS地图服务登录
|
||||||
|
narimap.SGAuth.login()
|
||||||
|
.then((result: any) => {
|
||||||
|
if (result.success) {
|
||||||
|
console.log('登录成功')
|
||||||
|
} else {
|
||||||
|
console.log('登录失败', result)
|
||||||
|
}
|
||||||
|
|
||||||
narimap.Require(['PSRMap', 'Thematic','ManageGrid', 'Components.Query','Components.MapSelector', 'Components.RegionSelector'], () => {
|
//默认打开电网GIS影像图
|
||||||
if (narimap.Config.examples.notlogin) {
|
initMap(narimap.Config.styles.sjRaster)
|
||||||
initMap(narimap.Config.styles.sjRaster)
|
})
|
||||||
} else {
|
.catch((err: any) => {
|
||||||
//电网GIS地图服务登录
|
console.log('错误', err)
|
||||||
narimap.SGAuth.login()
|
})
|
||||||
.then((result: any) => {
|
}
|
||||||
if (result.success) {
|
|
||||||
console.log('登录成功')
|
|
||||||
} else {
|
|
||||||
console.log('登录失败', result)
|
|
||||||
}
|
|
||||||
|
|
||||||
//默认打开电网GIS影像图
|
|
||||||
initMap(narimap.Config.styles.sjRaster)
|
|
||||||
})
|
|
||||||
.catch((err: any) => {
|
|
||||||
console.log('错误', err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
function initMap(styleurl: any) {
|
function initMap(styleurl: any) {
|
||||||
map.value = new narimap.Map({
|
map.value = new narimap.Map({
|
||||||
container: 'map',
|
container: 'map',
|
||||||
style: styleurl,
|
style: styleurl,
|
||||||
zoom: 6,
|
zoom: 6,
|
||||||
center: [116.478935, 39.997761],
|
center: [116.478935, 39.997761],
|
||||||
controls: false,
|
controls: ['attribute', 'navigation', 'geolocate', 'scale'],
|
||||||
country: true,
|
country: true,
|
||||||
// 地图默认字体
|
// 地图默认字体
|
||||||
localIdeographFontFamily: 'Microsoft YoHei'
|
localIdeographFontFamily: 'Microsoft YoHei',
|
||||||
|
fullExtent: narimap.Config.examples.fullExtent
|
||||||
})
|
})
|
||||||
|
|
||||||
map.value.on('load', () => {
|
map.value.on('load', () => {
|
||||||
createMapSelectorComponent()
|
createMapSelectorComponent()
|
||||||
DeviceQuery.value = new narimap.ResourceQuery.DeviceQuery()
|
DeviceQuery.value = new narimap.ResourceQuery.DeviceQuery()
|
||||||
addLayer()
|
addLayer()
|
||||||
|
//testAddLayer()
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
// 添加图层
|
// 添加图层
|
||||||
Query()
|
Query()
|
||||||
@@ -227,6 +243,7 @@ const Query = () => {
|
|||||||
cascade: true
|
cascade: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
powerManageGridMap.value.on('load', function () {
|
powerManageGridMap.value.on('load', function () {
|
||||||
powerLoad()
|
powerLoad()
|
||||||
})
|
})
|
||||||
@@ -282,7 +299,8 @@ const initDeviceCard = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deviceCard.value = new nrgisCommon.EquipmentAccount.DeviceCard(options)
|
deviceCard.value = new narimap.Components.DeviceCard(options)
|
||||||
|
|
||||||
deviceCard.value.on('click', (res: any) => {
|
deviceCard.value.on('click', (res: any) => {
|
||||||
if (res.button.id == 'nariPopupViewDetail') {
|
if (res.button.id == 'nariPopupViewDetail') {
|
||||||
emit('show', true)
|
emit('show', true)
|
||||||
@@ -535,26 +553,27 @@ const addLayer = () => {
|
|||||||
// 为图层设置引用的图片ID
|
// 为图层设置引用的图片ID
|
||||||
'icon-image': 'poi4',
|
'icon-image': 'poi4',
|
||||||
'icon-size': 0.35,
|
'icon-size': 0.35,
|
||||||
// 'text-field': '{name}',
|
// 'icon-pitch-alignment': 'map', //贴地
|
||||||
'icon-ignore-placement': false,
|
'icon-ignore-placement': false,
|
||||||
'icon-allow-overlap': false
|
'icon-allow-overlap': false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// 添加地图弹框
|
// 添加地图弹框
|
||||||
map.value.on('click', (e: any) => {
|
map.value.on('click', (e: any) => {
|
||||||
const features = map.value.queryRenderedFeatures(e.point, {
|
const features = map.value.queryRenderedFeatures(e.point, {
|
||||||
layers: ['spotImg-ZY', 'spotImg-TY', 'spotImg-GJ', 'spotImg-DW']
|
layers: ['spotImg-ZY', 'spotImg-TY', 'spotImg-GJ', 'spotImg-DW']
|
||||||
})
|
})
|
||||||
|
|
||||||
if (features.length > 0) {
|
if (features.length > 0) {
|
||||||
popup.value && popup.value.remove()
|
popup.value && popup.value.remove()
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
deviceCard.value.popup && deviceCard.value.popup.remove()
|
deviceCard.value.popup && deviceCard.value.popup.remove()
|
||||||
}, 10)
|
}, 10)
|
||||||
let data = JSON.parse(features[0].properties.list)
|
let data = JSON.parse(features[0].properties.list)
|
||||||
|
|
||||||
popup.value = new narimap.Popup({ offset: popupOffsets.value, className: 'my-popup' })
|
popup.value = new narimap.Popup({ offset: popupOffsets.value, className: 'my-popup' })
|
||||||
.setLngLat([data.lng, data.lat])
|
.setLngLat([data.lng, data.lat])
|
||||||
.setHTML(
|
.setHTML(
|
||||||
@@ -585,6 +604,7 @@ const addLayer = () => {
|
|||||||
</div>`
|
</div>`
|
||||||
)
|
)
|
||||||
.addTo(map.value)
|
.addTo(map.value)
|
||||||
|
|
||||||
let html = document.getElementById('ids')
|
let html = document.getElementById('ids')
|
||||||
if (html)
|
if (html)
|
||||||
html.onclick = function (v: any) {
|
html.onclick = function (v: any) {
|
||||||
@@ -596,7 +616,7 @@ const addLayer = () => {
|
|||||||
|
|
||||||
// 监听地图缩放完成事件
|
// 监听地图缩放完成事件
|
||||||
map.value.on('zoomend', (e: any) => {
|
map.value.on('zoomend', (e: any) => {
|
||||||
// console.log(123, map.value.getCenter())
|
console.log(123, map.value.getZoom())
|
||||||
|
|
||||||
if (map.value.getZoom() > 8.5 || map.value.getZoom() < 6) {
|
if (map.value.getZoom() > 8.5 || map.value.getZoom() < 6) {
|
||||||
rPopList.value.map((item: any) => item.remove())
|
rPopList.value.map((item: any) => item.remove())
|
||||||
@@ -606,6 +626,102 @@ const addLayer = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 测试添加点
|
||||||
|
const testAddLayer = () => {
|
||||||
|
// 注册图片
|
||||||
|
map.value.loadImage(
|
||||||
|
new URL('@/assets/test5.png', import.meta.url).href, // 图片地址
|
||||||
|
(error: any, image: any) => {
|
||||||
|
if (error) throw error
|
||||||
|
//添加图片到 map.value ,第一个参数为图片设置 id
|
||||||
|
map.value.addImage('poi5', image)
|
||||||
|
//添加 layer
|
||||||
|
map.value.addLayer({
|
||||||
|
id: 'test',
|
||||||
|
type: 'symbol',
|
||||||
|
minzoom: 6.5, //图片层级
|
||||||
|
source: {
|
||||||
|
type: 'geojson',
|
||||||
|
data: {
|
||||||
|
type: 'FeatureCollection',
|
||||||
|
features: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
layout: {
|
||||||
|
// 为图层设置引用的图片ID
|
||||||
|
'icon-image': 'poi5',
|
||||||
|
'icon-pitch-alignment': 'map', //贴地
|
||||||
|
'icon-ignore-placement': true,
|
||||||
|
'icon-allow-overlap': true,
|
||||||
|
'icon-anchor': 'center', // 中心点
|
||||||
|
'icon-size': ['interpolate', ['linear'], ['zoom'], 6, 0.1, 50, 1] // 图符大小
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// 添加图片需要先注册图片才能加载
|
||||||
|
setTimeout(() => {
|
||||||
|
map.value.getSource('test').setData({
|
||||||
|
type: 'FeatureCollection',
|
||||||
|
features: [
|
||||||
|
{
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: {
|
||||||
|
type: 'Point',
|
||||||
|
coordinates: [115.3544544, 40.217797]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: {
|
||||||
|
type: 'Point',
|
||||||
|
coordinates: [115.4544544, 40.317797]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
|
||||||
|
// 地图连线
|
||||||
|
map.value.addLayer({
|
||||||
|
id: 'power-line',
|
||||||
|
type: 'line',
|
||||||
|
source: {
|
||||||
|
type: 'geojson',
|
||||||
|
data: {
|
||||||
|
type: 'FeatureCollection',
|
||||||
|
features: [
|
||||||
|
{
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: {
|
||||||
|
type: 'MultiLineString', //MultiLineString3层数组可以绘制多条线 LineString2层数组
|
||||||
|
coordinates: [
|
||||||
|
[
|
||||||
|
[117, 39],
|
||||||
|
[116, 40]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[116, 39],
|
||||||
|
[115, 40]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
paint: {
|
||||||
|
'line-color': '#ff0000',
|
||||||
|
'line-width': 3,
|
||||||
|
'line-opacity': 0.6
|
||||||
|
}
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
//先判断是否有图层 'power-line'是图层注册id
|
||||||
|
if (map.value.getLayer('power-line')) map.value.removeLayer('power-line')
|
||||||
|
}, 5000)
|
||||||
|
}
|
||||||
//添加多个监测点
|
//添加多个监测点
|
||||||
const addMarkers = async (row?: any, key?: any, num?: any) => {
|
const addMarkers = async (row?: any, key?: any, num?: any) => {
|
||||||
if (map.value == null) return
|
if (map.value == null) return
|
||||||
@@ -772,7 +888,7 @@ const GridDiagramArea = () => {
|
|||||||
}
|
}
|
||||||
// 添加统计弹框
|
// 添加统计弹框
|
||||||
const radiusPop = (k?: number) => {
|
const radiusPop = (k?: number) => {
|
||||||
if (k != undefined) PopKey.value = k
|
if (k != undefined) PopKey.value = 0
|
||||||
if (rPopList.value.length > 0) {
|
if (rPopList.value.length > 0) {
|
||||||
rPopList.value.map((item: any) => item.remove())
|
rPopList.value.map((item: any) => item.remove())
|
||||||
rPopList.value = []
|
rPopList.value = []
|
||||||
@@ -984,10 +1100,9 @@ const flyTo = (row: any, zoom?: number) => {
|
|||||||
|
|
||||||
// 添加地图选择
|
// 添加地图选择
|
||||||
const createMapSelectorComponent = () => {
|
const createMapSelectorComponent = () => {
|
||||||
const mapSelector = new narimap.Components.MapSelector();
|
const mapSelector = new narimap.Components.MapSelector()
|
||||||
|
|
||||||
mapSelector.init(
|
mapSelector.init(
|
||||||
map.value,
|
map.value
|
||||||
// ['sjBase', 'sjDark'],
|
// ['sjBase', 'sjDark'],
|
||||||
// [
|
// [
|
||||||
// {
|
// {
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ const tableStore: any = new TableStore({
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
beforeSearchFun: () => {
|
beforeSearchFun: () => {
|
||||||
// tableStore.table.params.deptId = tableStore.table.params.deptIndex
|
tableStore.table.params.deptId = tableStore.table.params.deptIndex
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user