OpenLayers custom string, number and function functions are described here.
OpenLayers Base Types | OpenLayers custom string, number and function functions are described here. |
OpenLayers. | Contains convenience functions for string manipulation. |
Functions | |
startsWith | Test whether a string starts with another string. |
contains | Test whether a string contains another string. |
trim | Removes leading and trailing whitespace characters from a string. |
camelize | Camel-case a hyphenated string. |
format | Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object. |
OpenLayers. | Determine whether a string contains only a numeric value. |
numericIf | Converts a string that appears to be a numeric value into a number. |
String. | Deprecated. |
String. | Deprecated. |
String.trim | Deprecated. |
String. | Deprecated. |
OpenLayers. | Contains convenience functions for manipulating numbers. |
Functions | |
limitSigDigs | Limit the number of significant digits on a float. |
format | Formats a number for output. |
Number. | Deprecated. |
OpenLayers. | Contains convenience functions for function manipulation. |
Functions | |
bind | Bind a function to an object. |
bindAsEventListener | Bind a function to an object, and configure it to receive the event object as first parameter when called. |
Function.bind | Deprecated. |
Function. | Deprecated. |
OpenLayers. | Contains convenience functions for array manipulation. |
Functions | |
filter | Filter an array. |
Contains convenience functions for string manipulation.
Functions | |
startsWith | Test whether a string starts with another string. |
contains | Test whether a string contains another string. |
trim | Removes leading and trailing whitespace characters from a string. |
camelize | Camel-case a hyphenated string. |
format | Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object. |
OpenLayers. | Determine whether a string contains only a numeric value. |
numericIf | Converts a string that appears to be a numeric value into a number. |
String. | Deprecated. |
String. | Deprecated. |
String.trim | Deprecated. |
String. | Deprecated. |
format: function( template, context, args )
Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object. Represent a literal “${“ by doubling it, e.g. “${${“.
template | {String} A string with tokens to be replaced. A template has the form “literal ${token}” where the token will be replaced by the value of context[“token”]. |
context | {Object} An optional object with properties corresponding to the tokens in the format string. If no context is sent, the window object will be used. |
args | {Array} Optional arguments to pass to any functions found in the context. If a context property is a function, the token will be replaced by the return from the function called with these arguments. |
{String} A string with tokens replaced from the context object.
Determine whether a string contains only a numeric value.
OpenLayers.String.isNumeric("6.02e23") // true OpenLayers.String.isNumeric("12 dozen") // false OpenLayers.String.isNumeric("4") // true OpenLayers.String.isNumeric(" 4 ") // false
{Boolean} String contains only a number.
Contains convenience functions for manipulating numbers.
Functions | |
limitSigDigs | Limit the number of significant digits on a float. |
format | Formats a number for output. |
Number. | Deprecated. |
format: function( num, dec, tsep, dsep )
Formats a number for output.
num | {Float} |
dec | {Integer} Number of decimal places to round to. Defaults to 0. Set to null to leave decimal places unchanged. |
tsep | {String} Thousands separator. Default is “,”. |
dsep | {String} Decimal separator. Default is “.”. |
{String} A string representing the formatted number.
Contains convenience functions for function manipulation.
Functions | |
bind | Bind a function to an object. |
bindAsEventListener | Bind a function to an object, and configure it to receive the event object as first parameter when called. |
Function.bind | Deprecated. |
Function. | Deprecated. |
filter: function( array, callback, caller )
Filter an array. Provides the functionality of the Array.prototype.filter extension to the ECMA-262 standard. Where available, Array.prototype.filter will be used.
Based on well known example from http://developer.mozilla.org
array | {Array} The array to be filtered. This array is not mutated. Elements added to this array by the callback will not be visited. |
callback | {Function} A function that is called for each element in the array. If this function returns true, the element will be included in the return. The function will be called with three arguments: the element in the array, the index of that element, and the array itself. If the optional caller parameter is specified the callback will be called with this set to caller. |
caller | {Object} Optional object to be set as this when the callback is called. |
{Array} An array of elements from the passed in array for which the callback returns true.
Test whether a string starts with another string.
startsWith: function( str, sub )
Test whether a string contains another string.
contains: function( str, sub )
Removes leading and trailing whitespace characters from a string.
trim: function( str )
Camel-case a hyphenated string.
camelize: function( str )
Given a string with tokens in the form ${token}, return a string with tokens replaced with properties from the given context object.
format: function( template, context, args )
Converts a string that appears to be a numeric value into a number.
numericIf: function( value )
Limit the number of significant digits on a float.
limitSigDigs: function( num, sig )
Formats a number for output.
format: function( num, dec, tsep, dsep )
Bind a function to an object.
bind: function( func, object )
Bind a function to an object, and configure it to receive the event object as first parameter when called.
bindAsEventListener: function( func, object )
Filter an array.
filter: function( array, callback, caller )