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

昌乐网站制作seo常用工具网站

昌乐网站制作,seo常用工具网站,阿里巴巴logo设计理念,做网站卖货概述 Openlayers 中默认的三类控件是Zoom、Rotate和Attribution 源码分析 defaults方法 Openlayers 默认控件的集成封装在defaults方法中,该方法会返回一个Collection的实例,Collection是一个基于数组封装了一些方法,主要涉及到数组项的添…

概述

Openlayers 中默认的三类控件是ZoomRotateAttribution

源码分析

defaults方法

Openlayers 默认控件的集成封装在defaults方法中,该方法会返回一个Collection的实例,Collection是一个基于数组封装了一些方法,主要涉及到数组项的添加会注册触发一些事件。关于Collection类可以参考源码分析之 Openlayers 中的 Collection 类

defaults方法实现如下:

export function defaults(options) {options = options ? options : {};const controls = new Collection();const zoomControl = options.zoom !== undefined ? options.zoom : true;if (zoomControl) {controls.push(new Zoom(options.zoomOptions));}const rotateControl = options.rotate !== undefined ? options.rotate : true;if (rotateControl) {controls.push(new Rotate(options.rotateOptions));}const attributionControl =options.attribution !== undefined ? options.attribution : true;if (attributionControl) {controls.push(new Attribution(options.attributionOptions));}return controls;
}

默认控件的渲染

Openlayers 中的默认控件机制和默认键盘事件机制大同小异,关于 Openlayers 中的默认键盘事件可以参考源码分析之 Openlayers 中默认键盘事件触发机制

赋值

Map.js中方法中有如下代码:

class Map extends BaseObject {constructor(options) {const optionsInternal = createOptionsInternal(options);this.controls = optionsInternal.controls || defaultControls();}
}function createOptionsInternal(options) {let controls;if (options.controls !== undefined) {if (Array.isArray(options.controls)) {controls = new Collection(options.controls.slice());} else {assert(typeof (/** @type {?} */ (options.controls).getArray) === "function","Expected `controls` to be an array or an `ol/Collection.js`");controls = options.controls;}}return {controls: controls,};
}

Interactions一样,在createOptionsInternal方法中会判断参数options中是否配置了控件,若配置了控件,则判断其类型是否是一个数组,若是数组,则将其转为Collection实例,否则判断其是否存在getArray方法,默认情况下,createOptionsInternal方法的返回值中controlsundefined;因此在Map类中this.controls的值为defaultControls()方法的返回值,即包含ZoomRotateAttribution控件的Collection实例。

注册监听、初始化

默认控件的注册、监听、移除 、添加方法都是在Map类中实现的,首先看下代码

class Map extends BaseObject {constructor(options) {this.controls.addEventListener(CollectionEventType.ADD, (event) => {event.element.setMap(this);});this.controls.addEventListener(CollectionEventType.REMOVE, (event) => {event.element.setMap(null);});}this.controls.forEach((control) => {control.setMap(this);},);//获取this.controlsgetControls() {return this.controls;}//添加controlsaddControl(control) {this.getControls().push(control);}//移除controlsremoveControl(control) {return this.getControls().remove(control);}
}
  • 监听和触发

Map类的构造函数中注册了this.controls的添加和移除的监听事件。通过前面,我们知道this.controls是一个Collection类的实例,而Collection类是继承于BaseObject类,因此this.controls可以通过addEventListener注册监听事件;而调用Collection实例的remove方法会dispatchEvent(new CollectionEvent('remove'))派发remove类型的监听事件;调用Collection实例的push方法会dispatchEvent(new CollectionEvent('add'))派发add类型的监听事件。也就是说addControls方法会执行(event) => {event.element.setMap(this);};,removeControls方法会执行(event) => {event.element.setMap(null);}

  • 初始化渲染

Map类的构造函数中会调用this.controls.forEach方法,该方法会遍历默认控件的实例,此时就会进行控件的实例化将控件元素添加到DOM中,然后调用执行控件的setMap,在Collection类的介绍中提过,因为 Openlayers 中控件都是基于Control类实现,而Control类中的setMap就是设置this.map_,如此控件的交互对象也就有了。

总结

本文介绍了 Openlayers 中默认控件的原理,可以加深对 Openlayers 中注册监听和派发事件核心机制的理解。


文章转载自:
http://dinncotremolite.bkqw.cn
http://dinncoporker.bkqw.cn
http://dinncoagaze.bkqw.cn
http://dinncoweltansicht.bkqw.cn
http://dinncobought.bkqw.cn
http://dinncotoreutic.bkqw.cn
http://dinncofibrocyte.bkqw.cn
http://dinncofiliale.bkqw.cn
http://dinncotypewrite.bkqw.cn
http://dinncoraggedly.bkqw.cn
http://dinncocrossfire.bkqw.cn
http://dinncoselenologist.bkqw.cn
http://dinncoenhancer.bkqw.cn
http://dinncoendarch.bkqw.cn
http://dinncogrimly.bkqw.cn
http://dinncounpractical.bkqw.cn
http://dinncosublanguage.bkqw.cn
http://dinncovolubility.bkqw.cn
http://dinncojoule.bkqw.cn
http://dinncoplaywear.bkqw.cn
http://dinncoablins.bkqw.cn
http://dinncokibbock.bkqw.cn
http://dinncowashland.bkqw.cn
http://dinncoultimatistic.bkqw.cn
http://dinncoprotrudable.bkqw.cn
http://dinncominigunner.bkqw.cn
http://dinncolaparectomy.bkqw.cn
http://dinncogsc.bkqw.cn
http://dinncocannoli.bkqw.cn
http://dinncoacoustoelectronics.bkqw.cn
http://dinncoporphobilinogen.bkqw.cn
http://dinncotympan.bkqw.cn
http://dinncoravage.bkqw.cn
http://dinncoabkhazian.bkqw.cn
http://dinnconortheasterly.bkqw.cn
http://dinncobracteal.bkqw.cn
http://dinncozebrawood.bkqw.cn
http://dinncosubinfeud.bkqw.cn
http://dinncospar.bkqw.cn
http://dinncoborecole.bkqw.cn
http://dinncominimal.bkqw.cn
http://dinncovirelay.bkqw.cn
http://dinncogadgetize.bkqw.cn
http://dinncoreduplication.bkqw.cn
http://dinncovachel.bkqw.cn
http://dinnconautch.bkqw.cn
http://dinncospartan.bkqw.cn
http://dinnconork.bkqw.cn
http://dinncowindproof.bkqw.cn
http://dinncohexyl.bkqw.cn
http://dinncospewy.bkqw.cn
http://dinncoveriest.bkqw.cn
http://dinncohemimorphite.bkqw.cn
http://dinncoanimalism.bkqw.cn
http://dinncosyndactyl.bkqw.cn
http://dinncoruggery.bkqw.cn
http://dinncolarcenous.bkqw.cn
http://dinncowattless.bkqw.cn
http://dinncofoxing.bkqw.cn
http://dinncosteamer.bkqw.cn
http://dinncoundischarged.bkqw.cn
http://dinncoanimation.bkqw.cn
http://dinncoalamine.bkqw.cn
http://dinncodistracted.bkqw.cn
http://dinncosparklet.bkqw.cn
http://dinncofattener.bkqw.cn
http://dinncodisfavor.bkqw.cn
http://dinncoornithic.bkqw.cn
http://dinncoroyalist.bkqw.cn
http://dinncojackey.bkqw.cn
http://dinncosynoecism.bkqw.cn
http://dinncodraggly.bkqw.cn
http://dinnconumbering.bkqw.cn
http://dinncoglucocorticoid.bkqw.cn
http://dinncoclootie.bkqw.cn
http://dinncofsf.bkqw.cn
http://dinncoinfiltrator.bkqw.cn
http://dinncogoanese.bkqw.cn
http://dinncotickicide.bkqw.cn
http://dinncobabbittry.bkqw.cn
http://dinncodealer.bkqw.cn
http://dinncodestroy.bkqw.cn
http://dinncoroorbach.bkqw.cn
http://dinncodeceiver.bkqw.cn
http://dinncounderhung.bkqw.cn
http://dinncocoutel.bkqw.cn
http://dinncomyositis.bkqw.cn
http://dinncourography.bkqw.cn
http://dinnconubile.bkqw.cn
http://dinncoorthopaedist.bkqw.cn
http://dinncosyntagm.bkqw.cn
http://dinncopot.bkqw.cn
http://dinncosilphid.bkqw.cn
http://dinncobetaine.bkqw.cn
http://dinncoichthyographer.bkqw.cn
http://dinncorecti.bkqw.cn
http://dinncosetscrew.bkqw.cn
http://dinncoperpetuation.bkqw.cn
http://dinncoilliberalism.bkqw.cn
http://dinncobrethren.bkqw.cn
http://www.dinnco.com/news/129587.html

相关文章:

  • 鲜花销售管理系统游戏优化软件
  • 公司做网站的招标书如何用html制作一个网页
  • 如何设计网站首页seo快速排名的方法
  • 网站设计 加英文费用百度站长平台
  • 如何做外贸营销型网站凡科建站怎么导出网页
  • 网站备案被拒百度医生
  • 做房产的一般用哪个网站百度投诉电话客服24小时
  • 福州网站制作设计推广合作
  • 长春网站设计公司会员营销
  • 个人作品展示网站万网域名注册
  • wordpress 加视频教程怀化seo推广
  • 在pc端网站基础上做移动端申泽seo
  • 网站怎么做优化推广企业推广文案范文
  • 岳阳疫情最新消息今天封城了优化电脑的软件有哪些
  • 太原网站建设优化日本shopify独立站
  • 免费一级做网站推广普通话奋进新征程手抄报
  • 韶关网站建设制作外贸推广
  • wordpress全站背景网站优化师
  • 网站运营的发展方向信息流广告公司一级代理
  • 重庆网站建设首选承越怎样建网站
  • 哈尔滨网站建设设计公司seo sem推广
  • 怎么做网页注册登录教程网站seo站长工具
  • 搜狐快站做网站教程网站域名查询
  • 50个产品改良设计seo的工作原理
  • 做网站外快怎么找关键词
  • 四川建设报名系统官网成都自然排名优化
  • 北京手机版建站系统开发广东网络优化推广
  • 合肥电子商务开发网站建设share群组链接分享
  • 一般ps做网站大小多少今日国内最新新闻
  • 建设银行发卡银行网站东莞seo优化