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

有什么做vi设计的网站网页设计师培训学院

有什么做vi设计的网站,网页设计师培训学院,北京网站建设 合一,建材网站建设概述 本文主要介绍 Openlayers 中的MousePosition鼠标位置控件#xff0c;该控件会创建一个元素在页面的右上方用来实时显示鼠标光标的位置坐标。该控件在实际应用很有效#xff0c;可以实时获取鼠标位置#xff0c;但是一般控件元素都会自定义。 源码分析 MousePosition…概述 本文主要介绍 Openlayers 中的MousePosition鼠标位置控件该控件会创建一个元素在页面的右上方用来实时显示鼠标光标的位置坐标。该控件在实际应用很有效可以实时获取鼠标位置但是一般控件元素都会自定义。 源码分析 MousePosition类是继承于Control类关于Control类可以参考这篇文章源码分析之Openlayers中的控件篇Control基类介绍。 MousePosition类实现如下 class MousePosition extends Control {constructor(options) {options options ? options : {};const element document.createElement(div);element.className options.className ! undefined ? options.className : ol-mouse-position;super({element: element,render: options.render,target: options.target,});this.on;this.once;this.un;this.addChangeListener(PROJECTION, this.handleProjectionChanged_);if (options.coordinateFormat) {this.setCoordinateFormat(options.coordinateFormat);}if (options.projection) {this.setProjection(options.projection);}this.renderOnMouseOut_ options.placeholder ! undefined;this.placeholder_ this.renderOnMouseOut_ ? options.placeholder : #160;;this.renderedHTML_ element.innerHTML;this.mapProjection_ null;this.transform_ null;this.wrapX_ options.wrapX false ? false : true;}handleProjectionChanged_() {this.transform_ null;}getCoordinateFormat() {return this.get(COORDINATE_FORMAT);}handleMouseOut(event) {this.updateHTML_(null);}getProjection() {return this.get(PROJECTION);}handleMouseMove(event) {const map this.getMap();this.updateHTML_(map.getEventPixel(event));}setMap(map) {super.setMap(map);if (map) {const viewport map.getViewport();this.listenerKeys.push(listen(viewport, EventType.POINTERMOVE, this.handleMouseMove, this));if (this.renderOnMouseOut_) {this.listenerKeys.push(listen(viewport, EventType.POINTEROUT, this.handleMouseOut, this));}this.updateHTML_(null);}}setCoordinateFormat(format) {this.set(COORDINATE_FORMAT, format);}setProjection(projection) {this.set(PROJECTION, getProjection(projection));}updateHTML_(pixel) {let html this.placeholder_;if (pixel this.mapProjection_) {if (!this.transform_) {const projection this.getProjection();if (projection) {this.transform_ getTransformFromProjections(this.mapProjection_,projection);} else {this.transform_ identityTransform;}}const map this.getMap();const coordinate map.getCoordinateFromPixelInternal(pixel);if (coordinate) {const userProjection getUserProjection();if (userProjection) {this.transform_ getTransformFromProjections(this.mapProjection_,userProjection);}this.transform_(coordinate, coordinate);if (this.wrapX_) {const projection userProjection || this.getProjection() || this.mapProjection_;wrapX(coordinate, projection);}const coordinateFormat this.getCoordinateFormat();if (coordinateFormat) {html coordinateFormat(coordinate);} else {html coordinate.toString();}}}if (!this.renderedHTML_ || html ! this.renderedHTML_) {this.element.innerHTML html;this.renderedHTML_ html;}}render(mapEvent) {const frameState mapEvent.frameState;if (!frameState) {this.mapProjection_ null;} else {if (this.mapProjection_ ! frameState.viewState.projection) {this.mapProjection_ frameState.viewState.projection;this.transform_ null;}}} }MousePosition类构造函数 MousePosition类构造函数接受一个参数对象options该参数可以包含如下属性 className控件类名默认为ol-mouse-positionrender自定义render方法默认undefinedtarget控件容器默认undefinedcoordinateFormat坐标格式化默认undefinedprojection分辨率默认undefinedplaceholder提示填充字符wrapX是否水平方向重复延申 构造函数首先会先注册projection的监听事件this.handleProjectionChanged_,若该值发生变化则将this.transform_置null然后判断若options.coordinateFormat存在则调用this.setCoordinateFormat方法若options.projection存在则调用this.setProjection方法 MousePosition类中的方法 getCoordinateFormat方法获取坐标格式化getProjection方法获取投影handleMouseMove方法接受一个参数event该方法是鼠标在地图上移动时调用会更新控件的内容坐标的值getEventPixel就是根据参数event获取鼠标的位置以及viewport的某些属性然后计算屏幕坐标handleMouseOut方法鼠标移除地图时调用setCoordinateFormat方法设置坐标格式化setProjection方法设置投影updateHTML_方法:根据屏幕坐标获取地理坐标render方法在调用父类的setMap方法时会调用主要用于设置this.mapProject_setMap方法sepMap方法会在Map类中调用内部首先会调用父类的setMap方法然后判断参数map是否存在若存在则注册viewport视口对象pointermove类型的监听事件为this.handleMouseMove若构造函数参数options.placeholder设置了还会注册viewport的pointerout的this.handleMouseOut事件。 总结 本文主要介绍了 Openlayers 中MousePosition鼠标位置控件的源码实现核心就是注册viewport对象上pointermove类型的监听事件获取屏幕坐标然后调用内部方法map.getCoordinateFromPixelInternal将屏幕坐标转化为实际的地理位置坐标。
http://www.w-s-a.com/news/112813/

相关文章:

  • 怎样建网站最快广州网站建设工程
  • iis7 网站404错误信息12306网站很难做吗
  • 网站建设600元包公司设计图片大全
  • 网站建设费用怎么做分录做校园网站代码
  • 网站改版做重定向福州网站建设思企
  • 网站建设全流程企业形象网站开发业务范畴
  • wordpress无法查看站点西安优秀高端网站建设服务商
  • 固始网站制作熟悉免费的网络营销方式
  • 做网站到a5卖站赚钱搜索引擎优化代理
  • 沈阳网站建设包括win10优化
  • 做百度手机网站点击软网站seo优化徐州百度网络
  • 徐州专业网站制作标志设计作业
  • 自己可以做网站空间吗海天建设集团有限公司网站
  • 教学督导网站建设报告aspcms网站图片不显示
  • 网站开发公司成本是什么门户网站宣传方案
  • 上海 企业网站建设网站怎么开通微信支付
  • 饮料网站建设wordpress主题猫
  • 网站建设需要编码不有没有专门的网站做品牌授权的
  • 做爰在线网站免费空间列表
  • 网站外链建设工作总结郑州网站建设扌汉狮网络
  • 建设企业网站的需要多长时间网站使用说明书模板
  • 建网站首页图片哪里找263企业邮箱网页版登录
  • 盐城网站建设电话高端定制网站
  • 成都网站seo技术施工企业样板先行制度
  • 高端网站建设电话河北建筑工程信息网站
  • 亲 怎么给一个网站做备份财务系统有哪些软件
  • wordpress重新手机优化专家下载
  • 怎样把网站做成软件设计工作室怎么接单
  • html网站设计实例代码重庆多个区划定风险区
  • 推广方案设计同一个网站可以同时做竞价和优化