当前位置: 首页 > news >正文

网站建设的一些名词北京建网站

网站建设的一些名词,北京建网站,免费的网站域名查询浏览器,网站建设中 windows实现效果: 随着地图的缩放,展示对应缩放级别下的行政边界。 准备数据: 1.国家行政边界数据 (country.json) 2.省级行政边界数据 (province.json) 3.市级行政边界数据(city.json&…

实现效果:

随着地图的缩放,展示对应缩放级别下的行政边界。

准备数据:

1.国家行政边界数据 (country.json)

2.省级行政边界数据 (province.json)

3.市级行政边界数据(city.json)

数据形式类似于下图:

准备方法:

以下几种准备的方法可为公用方法,写在js文件中,在需要使用的vue文件中,直接引如使用。

1.加载geojson数据的方法

function addGeoJson(urlStr, colorStr, name, callback, alpha, lineAlpha) {let entity = null;if (!urlStr) return;return new Promise((resolve, reject) => {Cesium.GeoJsonDataSource.load(urlStr).then(dataSource => {polygonDataSource = dataSource;let color;dataSource.name = name;for (let i = 0; i < dataSource.entities.values.length; ++i) {entity = dataSource.entities.values[i];if (!entity.polygon) continue;color = Cesium.Color.fromCssColorString(colorStr).withAlpha(alpha);entity.polygon = new Cesium.PolygonGraphics({hierarchy: entity.polygon.hierarchy._value,outline: false,material: color,classificationType: Cesium.ClassificationType.TERRAIN,zIndex: 10,});entity.polyline = new Cesium.PolylineGraphics({positions: [...entity.polygon.hierarchy._value.positions, entity.polygon.hierarchy._value.positions[0]],width: 2,material: Cesium.Color.fromCssColorString(colorStr).withAlpha(lineAlpha),clampToGround: true,classificationType: Cesium.ClassificationType.TERRAIN,});entity.name = name;entity.elId = entity.properties._adcode._value;Cesium.Cartesian3.fromDegrees(entity.properties.centroid._value[0], entity.properties.centroid._value[1]),entity.cursor = true;}addGeoJsonData.push(dataSource);viewer.dataSources.add(dataSource);callback(dataSource.entities.values);resolve(entity);});});
}

2.获取zoom缩放级别的方法

// 获取层级高度
function heightToZoom() {// height 取整const height = Math.ceil(viewer.camera.positionCartographic.height);const A = 40487.57;const B = 0.00007096758;const C = 91610.74;const D = -40467.74;return (D + (A - D) / (1 + Math.pow(height / C, B))).toFixed(2);
}

3.隐藏或显示geojson数据的方法

// 隐藏或显示边界
function hidenModelByID(name, bool) {if (typeof name === 'string') {if(viewer.dataSources._dataSources) {viewer.dataSources._dataSources.forEach(item=>{if(item._name == name){item.show = bool}})}}
}

实现方式: 

实现思路:在页面初始化时将3种边界数据均加载,通过控制显隐来展示不同缩放级别下的数据。该种方法是为了避免两种缩放级别切换边界展示时加载间隙无边界的情况。

1.初始页面加载3种geojson数据

默认展示国界,剩下两种不展示,同时在mounted中添加监听方法

import provinceData from '@/assets/data/province.json'
import countryData from '@/assets/data/country.json'
import cityData from '@/assets/data/city.json'
import { heightToZoom } from '@/utils/utils'
import { addGeoJson, hidenModelByID } from '@/earth/others/addJsonProvince.js' // 上面添加geojson和隐藏geojson的方法export default {
data() {return {boundaryList: [{id: 'country',name: '国界',data: countryData,minimumLevel: 1,maximumLevel: 3.33,isloaded: true},{id: 'province',name: '省界',data: provinceData,minimumLevel: 3.33,maximumLevel: 4.99,isloaded: false},{id: 'city',name: '市界',data: cityData,minimumLevel: 4.99,maximumLevel: 20,isloaded: false}],countryEntity: null, // 国界实体provinceEntity: null, // 省界实体cityEntity: null, // 市界实体}}
mounted() {this.loadCountryData() // 默认添加国界this.getBoundary() // 添加监听},
methods: {
// 加载国界loadCountryData() {addGeoJson(countryData, '#25FF96', 'country', () => {}, 0.01, 1).then((entity) => {this.countryEntity = entity}) // 添加国界addGeoJson(provinceData, '#25FF96', 'province', () => {}, 0.01, 1).then((entity) => {this.provinceEntity = entityhidenModelByID('province', false)}) // 添加省界addGeoJson(cityData, '#25FF96', 'city', () => {}, 0.01, 1).then((entity) => {this.cityEntity = entityhidenModelByID('city', false)}) // 添加市界},
}
}

2. 添加鼠标缩放事件监听方法

      getBoundary() {hidenModelByID('country', true)hidenModelByID('province', false)hidenModelByID('city', false)viewer.camera.changed.addEventListener(this.cameraChangedListener)},

3.根据缩放层级进行不同geojson数据的展示

cameraChangedListener() {let that = thisconst currentZoomLevel = heightToZoom() // 准备方法中已经写了该方法直接引入使用console.log('zoomLevel', currentZoomLevel)// 根据当前缩放级别加载相应的边界数据that.boundaryList.forEach((boundary) => {if (currentZoomLevel >= boundary.minimumLevel && currentZoomLevel <= boundary.maximumLevel) {this.hiddenAllBoundary()hidenModelByID(boundary.id, true)}})},

4.重置所有geojson数据,仅是全部置为不展示,并没有移除监听 

// 隐藏所有的行政边界hiddenAllBoundary() {hidenModelByID('country', false)hidenModelByID('province', false)hidenModelByID('city', false)},

 5.页面不在需要geojson行政边界时,移除监听,避免影响其他操作

removeBoundary() {this.hiddenAllBoundary()viewer.camera.changed.removeEventListener(this.cameraChangedListener);},

http://www.yayakq.cn/news/40651/

相关文章:

  • 个人网站介绍立即注册
  • 个人网站后台管理成都网站营销seo多少费用
  • 政务门户网站建设买网站自己做
  • 做网站怎么写代码网页制作站点
  • 廊坊大城网站建设黑龙江新闻
  • 男男做暧网站免费弹性盒子做自适应网站
  • 无锡公共工程建设中心网站网络策划书一般包括哪些内容
  • 网站建设模板坏处中国建设行业网站
  • 塑料模板医疗网站优化公司
  • 孝义网站建设wordpress网站静态化
  • 吴中区做网站外贸是什么工作
  • 模板网站和定个人网站的留言板怎么做
  • 网站建设南通网络网站制作过程
  • 旅游网站的设计的前提门户网站建设招投标
  • 男女直接做的视频视频网站企业网站的设计与开发
  • 购物网站排名大全郑州网站科技
  • 顺德网站制作案例如何电子商务公司建设网站方案
  • 企业网站的规划与建设色系网站
  • 主机域名网站源码深圳展厅装修公司企业展厅设计公司
  • 服装网站目标企业网站建设主要包括哪些内容
  • 网站的ftp账号和密码是什么网站seo分析工具
  • 科技公司手机端网站app开发价格公司
  • 怎么做律所的官方网站南阳网页制作公司
  • 保健品网站建设案例网站建设方案书腾讯云
  • 新乡个人网站建设哪家好wordpress 积分系统
  • 福州免费企业建站上海网站设计与
  • 网页设计网站如何添加链接怎么在wordpress上设计
  • 网站分析百度 代码四川门户网站建设
  • 建设招标网网站达州市建设规划网站
  • 网站包括哪些主要内容wordpress 可以干嘛