Class: Util

Util

Utilities methods used internally. It is static and should not be initiated.

new Util() [source]


Members

  • (static, constant) exports.emptyImageUrl :String

  • Transparent 1X1 gif image
    from https://css-tricks.com/snippets/html/base64-encode-of-1x1px-transparent-gif/
    Type:
    • String

    Static Methods

  • (static) exports.extend(dest, …src) [source]

  • Merges the properties of sources into destination object.
    Parameter Type Description
    dest Object object to extend
    src repeatable Object sources
    Returns:
    Object:
  • (static) exports.isNil(obj) [source]

  • Whether the object is null or undefined.
    Parameter Type Description
    obj Object object
    Returns:
    Boolean:
  • (static) exports.isNumber(val) [source]

  • Whether val is a number and not a NaN.
    Parameter Type Description
    val Object val
    Returns:
    Boolean:
  • (static) exports.isInteger(n) [source]

  • Whether a number is an integer
    Parameter Type Description
    n Number
    Returns:
    Boolean:
  • (static) exports.isObject(obj) [source]

  • Whether the obj is a javascript object.
    Parameter Type Description
    obj Object object
    Returns:
    Boolean:
  • (static) exports.isString(obj) [source]

  • Check whether the object is a string
    Parameter Type Description
    obj Object
    Returns:
    Boolean:
  • (static) exports.isFunction(obj) [source]

  • Check whether the object is a function
    Parameter Type Description
    obj Object
    Returns:
    Boolean:
  • (static) exports.hasOwn(obj, key) [source]

  • Check whether the object owns the property.
    Parameter Type Description
    obj Object object
    key String property
    Returns:
    Boolean:
  • (static) exports.distanceToSegment(p, p1, p2) [source]

  • caculate the distance from a point to a segment.
    Parameter Type Description
    p Point
    p1 Point
    p2 Point
    Returns:
    Number: distance from p to (p1, p2)
  • (static) exports.pointInsidePolygon(p, points) [source]

  • Whether the coordinate is inside the polygon
    Parameter Type Description
    p Polygon polygon
    points Coordinate coordinate
    Returns:
    Boolean:
  • (static) exports.translateToSVGStyles(s) [source]

  • Translate symbol properties to SVG properties
    Parameter Type Description
    s Object object with symbol properties
    Returns:
    Object: object with SVG properties
  • (static) exports.getMarkerPathBase64(symbol) [source]

  • Get SVG Base64 String from a marker symbol with (markerType : path)
    Parameter Type Description
    symbol Object symbol with markerType of path
    Returns:
    String: SVG Base64 String
  • (static) exports.getExternalResources(symbol, toAbsolute) [source]

  • Get external resources from the given symbol
    Parameter Type Description
    symbol Object symbol
    toAbsolute Boolean whether convert url to aboslute
    Returns:
    Array.<String>: - resource urls
  • (static) exports.isGradient(g) [source]

  • Whether the color is a gradient
    Parameter Type Description
    g Object color to test
    Returns:
    Boolean:
  • (static) exports.getGradientStamp(g) [source]

  • Get stamp of a gradient color object.
    Parameter Type Description
    g Object gradient color object
    Returns:
    String: gradient stamp
  • (static) exports.getSymbolStamp(symbol) [source]

  • Get stamp of a symbol
    Parameter Type Description
    symbol Object | Array.<Object> symbol
    Returns:
    String: symbol's stamp
  • (static) exports.lowerSymbolOpacity(symbol, ratio) [source]

  • Reduce opacity of the color by ratio
    Parameter Type Description
    symbol Object | Array.<Object> symbols to set
    ratio Number ratio of opacity to reduce
    Returns:
    Object|Array.<Object>: new symbol or symbols
  • (static) exports.extendSymbol(symbol, …src) [source]

  • Merges the properties of sources into the symbol.
    Parameter Type Description
    symbol Object | Array.<Object> symbol to extend
    src repeatable Object sources
    Returns:
    Object|Array.<Object>: merged symbol
  • (static) requestAnimFrame(fn) [source]

  • Polyfill of RequestAnimationFrame
    Parameter Type Description
    fn function callback
    Returns:
    Number: request id
  • (static) cancelAnimFrame(request) [source]

  • Polyfill of cancelAnimationFrame
    Parameter Type Description
    request Number id

  • (static) exports.parseJSON(str) [source]

  • Parse a JSON string to a object
    Parameter Type Description
    str String a JSON string
    Returns:
    Object:
  • (static) exports.computeDegree(p1, p2) [source]

  • Compute degree bewteen 2 points.
    Parameter Type Description
    p1 Point point 1
    p2 Point point 2
    Returns:
    Number: degree between 2 points