当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS TimeSlider.stops用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/widgets/TimeSlider"], (TimeSlider) => { /* code goes here */ });

ESM: import TimeSlider from "@arcgis/core/widgets/TimeSlider";

类: esri/widgets/TimeSlider

继承: TimeSlider > Widget > Accessor

自从:用于 JavaScript 4.12 的 ArcGIS API

用法说明

TimeSlider.stops函数(或属性)的定义如下:

来自 Object

定义时间滑块上的特定位置,当操作时拇指将捕捉到该位置。如果未指定,将添加十个均匀间隔的停靠点。

对于连续滑动,将 stops 设置为 null

timeSlider.stops = null;

要定义规则间隔的停止点,请分别使用类型为 TimeIntervalTimeExtentintervaltimeExtent 属性解析对象。 timeExtent 属性是可选的,用于将停靠点限制在特定日期范围内。此属性对于在一周或一个月的特定日期开始停止非常有用。如果按间隔定义的停靠点导致超过 10,000 个停靠点,则视图模型将默认为 10 个均匀间隔的停靠点。

// Add yearly intervals starting from the beginning of the TimeSlider.
timeSlider.stops = {
  interval: {
    value: 1,
    unit: "years"
  }
};

除了将停靠点设置为时间间隔,TimeSlider 可以使用count 属性划分为均匀间隔的停靠点。与前面的方法类似,可以使用可选的 timeExtent 属性将划分限制在特定的日期范围内。

// Add stops at 15 evenly spaced intervals.
timeSlider.stops = {
  count: 15
};

对于不规则间隔的停靠点,只需分配一个日期数组,如下所示。

// Add nine irregular stops.
timeSlider.stops = {
  dates: [
    new Date(2000, 0, 1), new Date(2001, 3, 8), new Date(2002, 0, 10),
    new Date(2003, 12, 8), new Date(2004, 2, 19), new Date(2005, 7, 5),
    new Date(2006, 9, 11), new Date(2007, 11, 21), new Date(2008, 1, 10)
  ]
};

最后,要通过计数或间隔来约束或偏移除法,请使用可选的 timeExtent 属性。

// Add yearly stops from Christmas 2019 to Christmas 2029 only
timeSlider.stops = {
  interval: {
    value: 1,
    unit: "years"
  },
  timeExtent: {
    start: new Date(2019, 11, 25),
    end: new Date(2029, 11, 25)
  }
};

// Likewise, add stops that represent quarters of 2019 only.
timeSlider.stops = {
  count: 4,
  timeExtent: {
    start: new Date(2019, 0, 1),
    end: new Date(2020, 0, 1)
  }
};

默认值:{ count : 10 }

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 TimeSlider.stops。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。