| | |
| | | |
| | | <script> |
| | | |
| | | // 图层变量做声明 |
| | | var farmRegionLayer = null |
| | | var plotRegionLayer = null |
| | | var farmLogoLayer = null |
| | |
| | | global.viewer = null |
| | | } |
| | | |
| | | // 初始化地图 |
| | | function initViewer () { |
| | | // new Viewer(new 地图) |
| | | global.viewer = new global.DC.Viewer('viewer-container', { |
| | | contextOptions: { |
| | | webgl: { |
| | |
| | | |
| | | // global.viewer.scene.globe.depthTestAgainstTerrain = true |
| | | |
| | | // 已声明的图层添加到地图上 |
| | | farmRegionLayer = new global.DC.VectorLayer('farmRegionLayer') |
| | | global.viewer.addLayer(farmRegionLayer) |
| | | |
| | |
| | | siteEntitylayers = new global.DC.VectorLayer('siteEntitylayers') |
| | | global.viewer.addLayer(siteEntitylayers) |
| | | |
| | | if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) { // 判断是否支持图像渲染像素化处理 |
| | | // 判断是否支持图像渲染像素化处理 |
| | | if (global.DC.Namespace.Cesium.FeatureDetection.supportsImageRenderingPixelated()) { |
| | | global.viewer.setOptions({ |
| | | resolutionScale: window.devicePixelRatio |
| | | }) |
| | | } |
| | | |
| | | // 影像 |
| | | // 天地图 影像 |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.UrlTemplateImageryProvider({ |
| | | url: 'http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0', |
| | |
| | | |
| | | // http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer |
| | | |
| | | // arcgis服务添加 |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({ |
| | | url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengyjjddom/MapServer/WMTS', |
| | |
| | | }) |
| | | ) |
| | | |
| | | // arcgis服务添加 |
| | | global.viewer.imageryLayers.addImageryProvider( |
| | | new global.DC.Namespace.Cesium.WebMapTileServiceImageryProvider({ |
| | | url: 'http://arcgis.jxpskj.com:6080/arcgis/rest/services/nanchengdom/MapServer/WMTS', |
| | |
| | | // }) |
| | | // ) |
| | | |
| | | // 设置地图初始位置,角度等 |
| | | global.viewer.camera.setView({ |
| | | // Cesium的坐标是以地心为原点,一向指向南美洲,一向指向亚洲,一向指向北极州 |
| | | // fromDegrees()方法,将经纬度和高程转换为世界坐标 |
| | |
| | | global.DC.ready(initViewer) |
| | | }, |
| | | methods: { |
| | | /** |
| | | * 添加农场点及范围的方法 |
| | | * @param {*} positions 位置信息(范围信息) |
| | | * @param {*} item 农场对应的所有信息(接口返回的数据) |
| | | */ |
| | | addPolygon (positions, item) { |
| | | const that = this |
| | | |
| | |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 添加地块范围的方法 |
| | | * @param {*} positions 位置信息(范围信息) |
| | | * @param {*} item 地块对应的所有信息(接口返回的数据) |
| | | */ |
| | | addPlotPolygon (positions, item) { |
| | | const that = this |
| | | |
| | |
| | | addPlotLayers.push({ center, name: item.landName }) |
| | | }, |
| | | |
| | | /** |
| | | * 在图层中添加实体(点) |
| | | * @param {*} item 站点(某个设备)对应的所有参数(接口返回对应站点的数据) |
| | | * @param {*} url 图标地址 |
| | | */ |
| | | addSiteEntity (item, url) { |
| | | const that = this |
| | | |
| | |
| | | sitePositionsArray.push({ center, name: item.name, id: item.id }) |
| | | }, |
| | | |
| | | /** |
| | | * 设置中心点 |
| | | * @param {*} name 对应站点(农场范围)的中心点 --- 对应的名字 |
| | | */ |
| | | setCenter (name) { |
| | | let center |
| | | addLayers.forEach(item => { |
| | |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * 设置地块中心点 |
| | | * @param {*} name 对应站点(地块范围)的中心点 --- 对应的名字 |
| | | */ |
| | | setPlotCenter (name) { |
| | | let center |
| | | addPlotLayers.forEach(item => { |
| | |
| | | }) |
| | | }, |
| | | |
| | | /** |
| | | * 设置中心点 |
| | | * @param {*} name 对应站点(设备点)的中心点 --- 对应的名字 |
| | | */ |
| | | setSiteCenter (name) { |
| | | let center |
| | | sitePositionsArray.forEach(item => { |
| | |
| | | }) |
| | | }, |
| | | |
| | | // 经纬度测算中心位置 |
| | | /** |
| | | * 根据经纬度范围计算中心点位置 |
| | | * @param {*} arr 记录经纬度信息的数组 |
| | | */ |
| | | getCenter (arr) { |
| | | let centerLonLat = [] |
| | | if (arr.length) { |