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

网站设计过程中需要注意的问题网络营销策划的主要特点

网站设计过程中需要注意的问题,网络营销策划的主要特点,室内设计工作室简介,游戏私人服务器搭建实现效果: 随着地图的缩放,展示对应缩放级别下的行政边界。 准备数据: 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.hengruixuexiao.com/news/40682.html

相关文章:

  • 为什么简洁网站会受到用户欢迎网站如何赚钱
  • 深圳西乡网站建设互联网域名注册查询
  • 传奇网站一般怎么做的软文营销网站
  • 网站规划的意义做网站的公司哪家最好
  • 网页设计与网站建设基础网站自助建站系统
  • 建设银行wap网站友情下载网站
  • 网站里的聊天怎么做的关键词代发排名推广
  • vfp网站开发什么是网站外链
  • wordpress 关闭评论网站优化及推广
  • 微网站搭建流程专业的网页制作公司
  • 做外贸用哪些网站广州网站到首页排名
  • 属于您自己的网站建设湖北seo关键词排名优化软件
  • 深圳做高端企业网站建设公司品牌营销方案
  • 北京网络公司的网站seo网站排名优化公司哪家
  • 都有哪些可以做app的网站网站推广策划
  • seo百度网站排名软件百度一下官网
  • 主网站下建立子目录站sem优化托管公司
  • 自己怎样做网站文章关键词内链软文素材网
  • 自己做的网站打不开了百度平台我的订单查询在哪里
  • 昆明建个网站哪家便宜大数据营销的案例
  • wordpress上传音频 http错误短视频入口seo
  • 上海专业网站建设服务2345网址导航安装
  • 成都企业网站建设那家好企业培训视频
  • 源码超市网站源码企业宣传册模板
  • 投诉举报网站 建设方案5g网络优化培训
  • 网站建设中的英文广告营销策略
  • 商城购物网站建设网络营销的企业有哪些
  • 网站定位案例seo综合检测
  • 亚马逊品牌网站要怎么做网店推广是什么
  • 桃城网站建设域名查询万网