Util

Some of the code borrows from leaflet https://github.com/Leaflet/Leaflet/tree/master/src/core

new TS.Util()

Methods

static TS.Util.checkPosition(position)

Check position for validity
Name Type Description
position *

static TS.Util.convertArguments(argument)Object

转换参数
Name Type Description
argument arguments 可重复 参数
Returns:

static TS.Util.debounce(fn, delay)function

Creates a debounced function that delays invoking `fn` until after `delay`
Name Type Description
fn
delay
Returns:

static TS.Util.distinctValuesOfArray(arr)Array.<any>

返回数组的所有不同值。 使用 ES6 Set和...rest运算符放弃所有重复的值。
Name Type Description
arr Array.<any>
Returns:
Example:
const distinctValuesOfArray = arr => [...new Set(arr)];
   // distinctValuesOfArray([1,2,2,3,4,4,5]) -> [1,2,3,4,5]

static TS.Util.emptyImageUrl()string

Data URI string containing a base64-encoded empty GIF image. Used as a hack to free memory from unused images on WebKit-powered mobile devices (by setting image `src` to this string).
Returns:

static TS.Util.formatNum(num, digits)number

Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default.
Name Type Description
num
digits
Returns:

static TS.Util.merge(dest, sources)*

Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter.
Name Type Description
dest
sources 可重复
Returns:

static TS.Util.setOptions(obj, options)

Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`.
Name Type Description
obj *
options *

static TS.Util.splitWords(str)

Trims and splits the string on whitespace and returns the array of parts.
Name Type Description
str *

static TS.Util.StyleToJson(style)Object|*

序列化材质
Name Type Description
style
Returns:

static TS.Util.throttle(fn, delay)function

Creates a throttled function that only invokes `fn` at most once per
Name Type Description
fn
delay
Returns:

static TS.Util.trim(str)

Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)
Name Type Description
str *

static TS.Util.uuid(prefix)string

Generates uuid
Name Type Default Description
prefix D
Returns: