Legacy
Mapbox.js is no longer in active development. To learn more about our newer mapping tools see Mapbox GL JS.
You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.
Util
Various utility functions, used by Leaflet internally.
Methods
Method | Returns | Description |
---|---|---|
extend(
|
Object |
Merges the properties of the src object (or multiple objects) into dest object and returns the latter. Has an L.extend shortcut. |
bind(
|
Function |
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. |
stamp( <Object> obj ) |
String |
Applies a unique key to the object and returns that key. Has an L.stamp shortcut. |
requestAnimFrame(
|
Number |
Schedules fn to be executed when the browser repaints. When immediate is set, fn is called immediately if the browser doesn't have native support for requestAnimationFrame , otherwise it's delayed. Returns an id that can be used to cancel the request |
cancelAnimFrame(
|
- | Cancels a previous request to requestAnimFrame . |
limitExecByInterval(
|
Function |
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. |
falseFn() |
Function |
Returns a function which always returns false . |
formatNum(
|
Number |
Returns the number num rounded to digits decimals. |
splitWords(
|
String[] |
Trims and splits the string on whitespace and returns the array of parts. |
setOptions(
|
Object |
Merges the given properties to the options of the obj object, returning the resulting options. See Class options. Has an L.setOptions shortcut. |
getParamString(
|
String |
Converts an object into a parameter URL string, e.g. {a: "foo", b: "bar"} '?a=foo&b=bar' . |
template(
|
String |
Simple templating facility, accepts a template string of the form 'Hello {a}, {b}' and a data object like {a: 'foo', b: 'bar'} , returns evaluated string ('Hello foo, bar' ). You can also specify functions instead of strings for data values — they will be evaluated passing data as an argument. |
isArray(
|
Boolean |
Returns true if the given object is an array. |
trim(
|
String |
Trims the whitespace from both ends of the string and returns the result. |
Properties
Property | Type | Description |
---|---|---|
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). |