源码分析之Openlayers图层基类BaseLayer介绍

源码分析之Openlayers图层基类BaseLayer介绍

访问Openlayers网站(https://jinuss.github.io/Openlayers_map_pages/,网站是基于Vue3 + Openlayers,里面有大量的实践和案例。觉得还不错,可以 给个小星星Star,鼓励一波 https://github.***/Jinuss/OpenlayersMap哦~

概述

Layer图层是 Openlayers 中很重要的一个概念和部分,而无论是VectorLayer矢量图层还是VectorTileLayer瓦片图层都是继承BaseLayer实现的。本文主要介绍BaseLayer的核心部分以及实现。

源码剖析

BaseLayer类继承自BaseObject类,其实现如下:

class BaseLayer extends BaseObject {
   
   
  constructor(options) {
   
   
    super();
    this.on;
    this.once;
    this.un;
    this.background_ = options.background;
    const properties = Object.assign({
   
   }, options);
    if (typeof options.properties === "object") {
   
   
      delete properties.properties;
      Object.assign(properties, options.properties);
    }

    properties[LayerProperty.OPACITY] =
      options.opacity !== undefined ? options.opacity : 1;
    assert(
      typeof properties[LayerProperty.OPACITY] === "number",
      "Layer opacity must be a number"
    );

    properties[LayerProperty.VISIBLE] =
      options.visible !== undefined ? options.visible : true;
    properties[LayerProperty.Z_INDEX] = options.zIndex;
    properties[LayerProperty.MAX_RESOLUTION] =
      options.maxResolution !== undefined ? options.maxResolution : Infinity;
    properties[LayerProperty.MIN_RESOLUTION] =
      options.minResolution !== undefined ? options.minResolution : 0
转载请说明出处内容投诉
CSS教程网 » 源码分析之Openlayers图层基类BaseLayer介绍

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买