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


JavaScript ArcGIS ColorSizeSlider.inputParseFunction用法及代码示例


基本信息

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

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

ESM: import ColorSizeSlider from "@arcgis/core/widgets/smartMapping/ColorSizeSlider";

类: esri/widgets/smartMapping/ColorSizeSlider

继承: ColorSizeSlider > SmartMappingSliderBase > Widget > Accessor

自从:用于 JavaScript 4.12 的 ArcGIS API

用法说明

ColorSizeSlider.inputParseFunction函数(或属性)的定义如下:

inputParseFunction InputParser inherited


自从:ArcGIS 适用于 JavaScript 4.14 的 API

用于解析由 inputFormatFunction 格式化的滑块输入的函数。如果设置了 inputFormatFunction,则必须设置此属性。否则滑块值可能不会更新到预期位置。

覆盖默认输入解析,这是一个解析的浮点数。

例子:

// Parses the slider input (a string value) to a number value understandable to the slider
// This assumes the slider was already configured with an inputFormatFunction
// For example, if the input is 1.5k this function will parse
// it to a value of 1500
slider.inputParseFunction = function(value, type, index){
  let charLength = value.length;
  let valuePrefix = parseFloat(value.substring(0,charLength-1));
  let finalChar = value.substring(charLength-1);

  if(parseFloat(finalChar) >= 0){
    return parseFloat(value);
  }
  if(finalChar === "k"){
    return valuePrefix * 1000;
  }
  if(finalChar === "m"){
    return valuePrefix * 1000000;
  }
  return value;
}

相关用法


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