Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Util

Hierarchy

Index

Properties

Static emptyImageUrl

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).

Methods

Static bind

  • bind<T>(fn: T, obj: any): T
  • Returns a function which executes function fn with the given scope obj (so that this keyword refers to obj inside the function code). Has an L.bind shortcut.

    Type parameters

    • T: Function

    Parameters

    • fn: T
    • obj: any

    Returns T

Static extend

  • extend(dest: any, ...sources: any[]): any
  • Merges the properties of the src object (or multiple objects) into dest object and returns the latter. Has an L.extend shortcut.

    Parameters

    • dest: any
    • Rest ...sources: any[]

    Returns any

Static falseFn

  • falseFn(): function
  • Returns a function which always returns false.

    Returns function

      • (): boolean
      • Returns boolean

Static formatNum

  • formatNum(num: number, digits: number): number
  • Returns the number num rounded to digits decimals.

    Parameters

    • num: number
    • digits: number

    Returns number

Static getParamString

  • getParamString(obj: any): string
  • Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} translates to '?a=foo&b=bar'.

    Parameters

    • obj: any

    Returns string

Static isArray

  • isArray(obj: any): boolean
  • Returns true if the given object is an array.

    Parameters

    • obj: any

    Returns boolean

Static limitExecByInterval

  • limitExecByInterval<T>(fn: T, time: number, context?: any): T
  • Returns a wrapper around the function fn that makes sure it's called not more often than a certain time interval time, but as fast as possible otherwise (for example, it is used for checking and requesting new tiles while dragging the map), optionally passing the scope (context) in which the function will be called.

    Type parameters

    • T: Function

    Parameters

    • fn: T
    • time: number
    • Optional context: any

    Returns T

Static setOptions

  • setOptions(obj: any, options: any): any
  • Merges the given properties to the options of the obj object, returning the resulting options. See Class options. Has an L.setOptions shortcut.

    Parameters

    • obj: any
    • options: any

    Returns any

Static splitWords

  • splitWords(str: string): string[]
  • Trims and splits the string on whitespace and returns the array of parts.

    Parameters

    • str: string

    Returns string[]

Static stamp

  • stamp(obj: any): string
  • Applies a unique key to the object and returns that key. Has an L.stamp shortcut.

    Parameters

    • obj: any

    Returns string

Static template

  • template(str: string, data: any): string
  • Simple templating facility, creates a string by applying the values of the data object of a form {a: 'foo', b: 'bar', …} to a template string of the form 'Hello {a}, {b}' — in this example you will get 'Hello foo, bar'.

    Parameters

    • str: string
    • data: any

    Returns string

Static trim

  • trim(str: string): string
  • Trims the whitespace from both ends of the string and returns the result.

    Parameters

    • str: string

    Returns string