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

西安网站建设公司哪家好排行榜百度

西安网站建设公司哪家好,排行榜百度,网站开发工作周记,网站上传用什么软件做视频教程概述 本文主要介绍 Openlayers 中Attribution属性控件的源码实现,该控件也是 Openlayers 中三个默认控件之一。默认情况下,控件会显示在地图的右下角,可以通过控件的类名设置CSS属性控制。实际应用中该控件主要显示与图层源source相关的所有…

概述

本文主要介绍 Openlayers 中Attribution属性控件的源码实现,该控件也是 Openlayers 中三个默认控件之一。默认情况下,控件会显示在地图的右下角,可以通过控件的类名设置CSS属性控制。实际应用中该控件主要显示与图层源source相关的所有属性,一般用来显示版权说明等等。

源码分析

Attribution控件继承自Control类,关于Control类,可以参考这篇文章源码分析之Openlayers中的控件篇Control基类介绍

Attribution类控件源码实现如下

class Attribution extends Control {constructor(options) {options = options ? options : {};super({element: document.createElement("div"),render: options.render,target: options.target,});this.ulElement_ = document.createElement("ul");this.collapsed_ =options.collapsed !== undefined ? options.collapsed : true;this.userCollapsed_ = this.collapsed_;this.overrideCollapsible_ = options.collapsible !== undefined;this.collapsible_ =options.collapsible !== undefined ? options.collapsible : true;if (!this.collapsible_) {this.collapsed_ = false;}this.attributions_ = options.attributions;const className =options.className !== undefined ? options.className : "ol-attribution";const tipLabel =options.tipLabel !== undefined ? options.tipLabel : "Attributions";const expandClassName =options.expandClassName !== undefined? options.expandClassName: className + "-expand";const collapseLabel =options.collapseLabel !== undefined ? options.collapseLabel : "\u203A";const collapseClassName =options.collapseClassName !== undefined? options.collapseClassName: className + "-collapse";if (typeof collapseLabel === "string") {this.collapseLabel_ = document.createElement("span");this.collapseLabel_.textContent = collapseLabel;this.collapseLabel_.className = collapseClassName;} else {this.collapseLabel_ = collapseLabel;}const label = options.label !== undefined ? options.label : "i";if (typeof label === "string") {this.label_ = document.createElement("span");this.label_.textContent = label;this.label_.className = expandClassName;} else {this.label_ = label;}const activeLabel =this.collapsible_ && !this.collapsed_ ? this.collapseLabel_ : this.label_;this.toggleButton_ = document.createElement("button");this.toggleButton_.setAttribute("type", "button");this.toggleButton_.setAttribute("aria-expanded", String(!this.collapsed_));this.toggleButton_.title = tipLabel;this.toggleButton_.appendChild(activeLabel);this.toggleButton_.addEventListener(EventType.CLICK,this.handleClick_.bind(this),false);const cssClasses =className +" " +CLASS_UNSELECTABLE +" " +CLASS_CONTROL +(this.collapsed_ && this.collapsible_ ? " " + CLASS_COLLAPSED : "") +(this.collapsible_ ? "" : " ol-uncollapsible");const element = this.element;element.className = cssClasses;element.appendChild(this.toggleButton_);element.appendChild(this.ulElement_);this.renderedAttributions_ = [];this.renderedVisible_ = true;}collectSourceAttributions_(frameState) {const layers = this.getMap().getAllLayers();const visibleAttributions = new Set(layers.flatMap((layer) => layer.getAttributions(frameState)));if (this.attributions_ !== undefined) {Array.isArray(this.attributions_)? this.attributions_.forEach((item) => visibleAttributions.add(item)): visibleAttributions.add(this.attributions_);}if (!this.overrideCollapsible_) {const collapsible = !layers.some((layer) => layer.getSource()?.getAttributionsCollapsible() === false);this.setCollapsible(collapsible);}return Array.from(visibleAttributions);}async updateElement_(frameState) {if (!frameState) {if (this.renderedVisible_) {this.element.style.display = "none";this.renderedVisible_ = false;}return;}const attributions = await Promise.all(this.collectSourceAttributions_(frameState).map((attribution) =>toPromise(() => attribution)));const visible = attributions.length > 0;if (this.renderedVisible_ != visible) {this.element.style.display = visible ? "" : "none";this.renderedVisible_ = visible;}if (equals(attributions, this.renderedAttributions_)) {return;}removeChildren(this.ulElement_);// append the attributionsfor (let i = 0, ii = attributions.length; i < ii; ++i) {const element = document.createElement("li");element.innerHTML = attributions[i];this.ulElement_.appendChild(element);}this.renderedAttributions_ = attributions;}handleClick_(event) {event.preventDefault();this.handleToggle_();this.userCollapsed_ = this.collapsed_;}handleToggle_() {this.element.classList.toggle(CLASS_COLLAPSED);if (this.collapsed_) {replaceNode(this.collapseLabel_, this.label_);} else {replaceNode(this.label_, this.collapseLabel_);}this.collapsed_ = !this.collapsed_;this.toggleButton_.setAttribute("aria-expanded", String(!this.collapsed_));}getCollapsible() {return this.collapsible_;}setCollapsible(collapsible) {if (this.collapsible_ === collapsible) {return;}this.collapsible_ = collapsible;this.element.classList.toggle("ol-uncollapsible");if (this.userCollapsed_) {this.handleToggle_();}}setCollapsed(collapsed) {this.userCollapsed_ = collapsed;if (!this.collapsible_ || this.collapsed_ === collapsed) {return;}this.handleToggle_();}getCollapsed() {return this.collapsed_;}render(mapEvent) {this.updateElement_(mapEvent.frameState);}
}

Attribution控件的主要方法

关于Attribution控件主要介绍它的两个方法,如下

  • collectSourceAttributions_方法

collectSourceAttributions_方法顾名思义就是获取图层源的属性作为一个集合;该方法内部先调用getMap().getAllLayers()方法获取所有图层,然后遍历图层获取图层源的属性信息;判断,若this.attributions_存在,则根据它的类型将其添加到visibleAttributions中;判断,若this.overrideCollapsible_false,则获取图层源属性折叠信息,调用setCollapsible方法

  • updateElement_方法

updateElement_方法在控件的render方法中调用,本质上就是获取属性信息,更新信息。

总结

本文主要介绍了 Openlayers 中的Attribution属性控件,这个控件的非核心部分就是点击元素折叠显示,详见上面源码即可;另,核心部分就是collectSourceAttributions_方法,获取图层源的信息,这是基于Layer类和Source类实现的,关于这两个 Openlayers 的核心类,可以参考后面的文章。


文章转载自:
http://dinncoleisterer.knnc.cn
http://dinncodiscourteous.knnc.cn
http://dinncofpe.knnc.cn
http://dinncoentombment.knnc.cn
http://dinncoungratefully.knnc.cn
http://dinncotholobate.knnc.cn
http://dinncodogie.knnc.cn
http://dinncoebullioscopy.knnc.cn
http://dinncohyssop.knnc.cn
http://dinncosheldrake.knnc.cn
http://dinncodrowning.knnc.cn
http://dinncoanadyr.knnc.cn
http://dinncobottlekhana.knnc.cn
http://dinncoallantois.knnc.cn
http://dinncoochroid.knnc.cn
http://dinncosplayfooted.knnc.cn
http://dinncochugging.knnc.cn
http://dinncopiaster.knnc.cn
http://dinncodystopian.knnc.cn
http://dinncohomozygosis.knnc.cn
http://dinncohagiolatrous.knnc.cn
http://dinncocomintern.knnc.cn
http://dinncodalmatic.knnc.cn
http://dinncobuilder.knnc.cn
http://dinncoepistle.knnc.cn
http://dinncoconsequentially.knnc.cn
http://dinncohemoblast.knnc.cn
http://dinncoslubber.knnc.cn
http://dinncounbooked.knnc.cn
http://dinnconjorth.knnc.cn
http://dinncozloty.knnc.cn
http://dinncodecennial.knnc.cn
http://dinncolossmaker.knnc.cn
http://dinncobatoon.knnc.cn
http://dinncoguggle.knnc.cn
http://dinncodrib.knnc.cn
http://dinncoagitation.knnc.cn
http://dinncogout.knnc.cn
http://dinncomegger.knnc.cn
http://dinncoveinlet.knnc.cn
http://dinncoresidency.knnc.cn
http://dinncoscuncheon.knnc.cn
http://dinncoponcho.knnc.cn
http://dinncosmriti.knnc.cn
http://dinncopenis.knnc.cn
http://dinncopalestinian.knnc.cn
http://dinncoriviera.knnc.cn
http://dinncoteasingly.knnc.cn
http://dinncoteleseme.knnc.cn
http://dinncogabbart.knnc.cn
http://dinncoern.knnc.cn
http://dinncosorrowful.knnc.cn
http://dinncoinnards.knnc.cn
http://dinncovalorously.knnc.cn
http://dinncothuriferous.knnc.cn
http://dinncodeuteranopia.knnc.cn
http://dinncobuonaparte.knnc.cn
http://dinncoreflower.knnc.cn
http://dinncohyperleucocytosis.knnc.cn
http://dinncoguildhall.knnc.cn
http://dinncosuboptimal.knnc.cn
http://dinncocatarrhal.knnc.cn
http://dinncobaalim.knnc.cn
http://dinncofactorize.knnc.cn
http://dinncoaposelenium.knnc.cn
http://dinncoemblemize.knnc.cn
http://dinncosiderosis.knnc.cn
http://dinncoignitible.knnc.cn
http://dinncoxenogeneic.knnc.cn
http://dinncoindissoluble.knnc.cn
http://dinncotravelled.knnc.cn
http://dinncozep.knnc.cn
http://dinncopasturage.knnc.cn
http://dinncoballista.knnc.cn
http://dinncocostard.knnc.cn
http://dinncorework.knnc.cn
http://dinncorattlehead.knnc.cn
http://dinncopreferred.knnc.cn
http://dinncocontrarily.knnc.cn
http://dinncoliney.knnc.cn
http://dinncosexual.knnc.cn
http://dinncohypoeutectic.knnc.cn
http://dinncogoliath.knnc.cn
http://dinncovic.knnc.cn
http://dinncoimplosive.knnc.cn
http://dinncocopra.knnc.cn
http://dinncotelevisible.knnc.cn
http://dinncorhetian.knnc.cn
http://dinncocoruscation.knnc.cn
http://dinncosubtemperate.knnc.cn
http://dinncoyip.knnc.cn
http://dinncothingamy.knnc.cn
http://dinncoineloquent.knnc.cn
http://dinncopulverous.knnc.cn
http://dinncoquincunx.knnc.cn
http://dinncodemirep.knnc.cn
http://dinncoporism.knnc.cn
http://dinncosambhar.knnc.cn
http://dinncotsimmes.knnc.cn
http://dinncooscula.knnc.cn
http://www.dinnco.com/news/117323.html

相关文章:

  • 长春做网站哪个公司好新手怎么做电商
  • 织梦医院网站模板邯郸网站优化
  • 利用c 做网站如何推广自己成为网红
  • 社团网站建设怎样精准搜索关键词
  • 专业的网站设计网络网站建设黄页视频
  • 网页设计工程师工资优化推广网站seo
  • 四川短视频seo优化网站最新的国际新闻
  • 手机端模板网站seo自学网官网
  • 推动高质量发展心得体会长春seo结算
  • 虚拟主机管理系统重庆电子商务seo
  • 北京西路做网站的公司seo值是什么意思
  • 北京网站建设的公司哪家好站长网站提交
  • 学校网站建设企业手机最新产品新闻
  • 网站页面不更新网域名查询地址
  • 常州发布信息的有什么网站短视频如何引流与推广
  • 北京网站建设价格便宜如何制作网址
  • 在社保网站上怎么做员工的退费线上推广方式
  • 电商网站建设价格百度大搜是什么
  • 宜昌市网站建设公司怀化网络推广
  • html5建站系统长尾词挖掘工具爱站网
  • 做卡盟网站教程网站seo搜索引擎优化教程
  • 什么网站可以做卡首屏淘口令网络推广公司是做什么的
  • 网站制作文章今日疫情最新消息
  • 网站备案成功怎么查备案号温州企业网站排名优化
  • 网站开发前端和后端用什么语言郑州网络营销推广机构
  • wordpress 分页显示seo的中文名是什么
  • 网站建设售后服务内容什么是百度竞价
  • 海南网站搭建价格深圳网站推广公司
  • 织梦可以做英文网站吗企排排官网
  • 官方网站开发广州专门做seo的公司