UtilSummary | | | | | This is the old $() from prototype | | Copy all properties of a source object to a destination object. | | Remove an object from an array. | | | | Seems to exist already in FF, but not in MOZ. | | Modifies many properties of a DOM element all at once. | | Creates a new div and optionally set some standard attributes. | | | | Creates an img element with specific attribute values. | | | | | | {String} The color tiles with load errors will turn. | | {Integer} How many times should we try to reload an image before giving up? | | | | Checks whether it’s necessary (and possible) to use the png alpha hack which allows alpha transparency for png images under Internet Explorer. | | | | | | Creates a new hashtable and copies over all the keys from the passed-in object, but storing them under an uppercased version of the key at which they were stored. | | Takes a hashtable and copies any keys that don’t exist from another hashtable, by analogy with OpenLayers.Util.extend() from Prototype.js. | | | | | | {String} The fully formatted image location string | | Execute functions until one of them doesn’t throw an error. | | These could/should be made namespace aware? | | | | | | | | | | | | | | Parse the parameters from a URL or from the current page itself into a JavaScript Object. | | | | {Integer} The ever-incrementing count variable. | | prefix {String} String to prefix unique id. | | | | {Object} Constant inches per unit -- borrowed from MapServer mapscale.c | | {Integer} 72 (A sensible default) | | | | | | | | | | | | Calculates the position of an element on the page. | | Test two URLs for equivalence. | | | | Takes a url and removes everything after the ? | | {String} A string which specifies which is the current browser in which we are running. |
getElementOpenLayers.Util.getElement = function() |
This is the old $() from prototype
extendOpenLayers.Util.extend = function( | destination, | | source | ) |
|
Copy all properties of a source object to a destination object. Modifies the passed in destination object. Parametersdestination | {Object} The object that will be modified | source | {Object} The object with properties to be set on the destination |
Returns{Object} The destination object.
removeItemOpenLayers.Util.removeItem = function( | array, | | item | ) |
|
Remove an object from an array. Iterates through the array to find the item, then removes it. ParametersReturn {Array} A reference to the array
clearArrayOpenLayers.Util.clearArray = function( | array | ) |
|
Deprecated. This function will disappear in 3.0. Please use “array.length = 0” instead. Parameters
indexOfOpenLayers.Util.indexOf = function( | array, | | obj | ) |
|
Seems to exist already in FF, but not in MOZ. ParametersReturns{Integer} The index at, which the object was found in the array. If not found, returns -1.v
modifyDOMElementOpenLayers.Util.modifyDOMElement = function( | element, | | id, | | px, | | sz, | | position, | | border, | | overflow, | | opacity | ) |
|
Modifies many properties of a DOM element all at once. Passing in null to an individual parameter will avoid setting the attribute. Parametersid | {String} The element id attribute to set. | px | {OpenLayers.Pixel} The left and top style position. | sz | {OpenLayers.Size} The width and height style attributes. | position | {String} The position attribute. eg: absolute, relative, etc. | border | {String} The style.border attribute. eg: solid black 2px | overflow | {String} The style.overview attribute. | opacity | {Float} Fractional value (0.0 - 1.0) |
createDivCreates a new div and optionally set some standard attributes. Null may be passed to each parameter if you do not wish to set a particular attribute.d
zIndex is NOT setParametersid | {String} An identifier for this element. If no id is passed an identifier will be created automatically. | px | {OpenLayers.Pixel} The element left and top position. | sz | {OpenLayers.Size} The element width and height. | imgURL | {String} A url pointing to an image to use as a background image. | position | {String} The style.position value. eg: absolute, relative etc. | border | {String} The the style.border value. eg: 2px solid black | overflow | {String} The style.overflow value. Eg. hidden | opacity | {Float} Fractional value (0.0 - 1.0) |
Returns{DOMElement} A DOM Div created with the specified attributes.
createImageOpenLayers.Util.createImage = function( | id, | | px, | | sz, | | imgURL, | | position, | | border, | | opacity, | | delayDisplay | ) |
|
Creates an img element with specific attribute values. Parametersid | {String} The id field for the img. If none assigned one will be automatically generated. | px | {OpenLayers.Pixel} The left and top positions. | sz | {OpenLayers.Size} The style.width and style.height values. | imgURL | {String} The url to use as the image source. | position | {String} The style.position value. | border | {String} The border to place around the image. | delayDisplay | {Boolean} If true waits until the image has been loaded. | opacity | {Float} Fractional value (0.0 - 1.0) |
Returns{DOMElement} A DOM Image created with the specified attributes.
setOpacityOpenLayers.Util.setOpacity = function( | element, | | opacity | ) |
|
Deprecated. This function has been deprecated. Instead, please use OpenLayers.Util.modifyDOMElement() or OpenLayers.Util.modifyAlphaImageDiv() Set the opacity of a DOM Element Note that for this function to work in IE, elements must “have layout” according to: http://msdn.microsoft.com- /workshop- /author- /dhtml- /reference- /properties- /haslayout.asp Parameterselement | {DOMElement} Set the opacity on this DOM element | opacity | {Float} Opacity value (0.0 - 1.0) |
onImageLoadOpenLayers.Util.onImageLoad = function() |
onImageLoadErrorColor{String} The color tiles with load errors will turn. Default is “pink”
onImageLoadErrorColor{Integer} How many times should we try to reload an image before giving up? Default is 0
onImageLoadErrorOpenLayers.Util.onImageLoadError = function() |
alphaHackOpenLayers.Util.alphaHack = function() |
Checks whether it’s necessary (and possible) to use the png alpha hack which allows alpha transparency for png images under Internet Explorer. Returns{Boolean} true if alpha has is necessary and possible, false otherwise.
modifyAlphaImageDivOpenLayers.Util.modifyAlphaImageDiv = function( | div, | | id, | | px, | | sz, | | imgURL, | | position, | | border, | | sizing, | | opacity | ) |
|
div | {DOMElement} Div containing Alpha-adjusted Image | id | {String} | px | {OpenLayers.Pixel} | sz | {OpenLayers.Size} | imgURL | {String} | position | {String} | border | {String} sizing {String} ‘crop’, ‘scale’, or ‘image’. Default is “scale” | opacity | {Float} Fractional value (0.0 - 1.0) |
createAlphaImageDivOpenLayers.Util.createAlphaImageDiv = function( | id, | | px, | | sz, | | imgURL, | | position, | | border, | | sizing, | | opacity, | | delayDisplay | ) |
|
id | {String} | px | {OpenLayers.Pixel} | sz | {OpenLayers.Size} | imgURL | {String} | position | {String} | border | {String} sizing {String} ‘crop’, ‘scale’, or ‘image’. Default is “scale” delayDisplay{Boolean} |
Returns{DOMElement} A DOM Div created with a DOM Image inside it. If the hack is needed for transparency in IE, it is added.
upperCaseObjectOpenLayers.Util.upperCaseObject = function ( | object | ) |
|
Creates a new hashtable and copies over all the keys from the passed-in object, but storing them under an uppercased version of the key at which they were stored. ParametersReturns{Object} A new Object with all the same keys but uppercased
applyDefaultsOpenLayers.Util.applyDefaults = function ( | to, | | from | ) |
|
Takes a hashtable and copies any keys that don’t exist from another hashtable, by analogy with OpenLayers.Util.extend() from Prototype.js. Parameters
getParameterStringOpenLayers.Util.getParameterString = function( | params | ) |
|
ParametersReturns{String} A concatenation of the properties of an object in http parameter notation. (ex. <i>”key1=value1&key2=value2&key3=value3”</i>) If a parameter is actually a list, that parameter will then be set to a comma-seperated list of values (foo,bar) instead of being URL escaped (foo%3Abar).
getImagesLocationOpenLayers.Util.getImagesLocation = function() |
Returns{String} The fully formatted image location string
TryOpenLayers.Util.Try = function() |
Execute functions until one of them doesn’t throw an error. Capitalized because “try” is a reserved word in JavaScript. Taken directly from OpenLayers.Util.Try() Parameters[*] | {Function} Any number of parameters may be passed to Try() It will attempt to execute each of them until one of them successfully executes. If none executes successfully, returns null. |
Returns{*} The value returned by the first successfully executed function.
getNodesOpenLayers.Util.getNodes=function( | p, | | tagName | ) |
|
These could/should be made namespace aware? ParametersReturns{Array}
_getNodesOpenLayers.Util._getNodes=function( | nodes, | | tagName | ) |
|
Parametersnodes | {Array} | tagName | {String} |
Returns{Array}
getTagTextOpenLayers.Util.getTagText = function ( | parent, | | item, | | index | ) |
|
Parametersparent | {} | item | {String} | index | {Integer} |
Returns{String}
getXmlNodeValueOpenLayers.Util.getXmlNodeValue = function( | node | ) |
|
ParametersReturns{String} The text value of the given node, without breaking in firefox or IE
mouseLeftOpenLayers.Util.mouseLeft = function ( | evt, | | div | ) |
|
Parametersevt | {Event} | div | {HTMLDivElement} |
Returns{Boolean}
radOpenLayers.Util.rad = function( | x | ) |
|
ParametersReturns{Float}
distVincentyOpenLayers.Util.distVincenty=function( | p1, | | p2 | ) |
|
ParametersReturns{Float}
getParametersOpenLayers.Util.getParameters = function( | url | ) |
|
Parse the parameters from a URL or from the current page itself into a JavaScript Object. Note that parameter values with commas are separated out into an Array. Parametersurl | {String} Optional url used to extract the query string. If null, query string is taken from page location. |
Returns{Object} An object of key/value pairs from the query string.
getArgsOpenLayers.Util.getArgs = function( | url | ) |
|
Deprecated | Will be removed in 3.0. Please use instead OpenLayers.Util.getParameters |
Parametersurl | {String} Optional url used to extract the query string. If null, query string is taken from page location. |
Returns{Object} An object of key/value pairs from the query string.
lastSeqID{Integer} The ever-incrementing count variable. Used for generating unique ids.
createUniqueIDOpenLayers.Util.createUniqueID = function( | prefix | ) |
|
Parametersprefix {String} String to prefix unique id. If null, default is “id_” Returns{String} A unique id string, built on the passed in prefix
INCHES_PER_UNIT{Object} Constant inches per unit -- borrowed from MapServer mapscale.c
DOTS_PER_INCH{Integer} 72 (A sensible default)
normalzeScaleParametersReturns{Float} A normalized scale value, in 1 / X format. This means that if a value less than one ( already 1/x) is passed in, it just returns scale directly. Otherwise, it returns 1 / scale
getResolutionFromScaleOpenLayers.Util.getResolutionFromScale = function ( | scale, | | units | ) |
|
Parametersscale | {Float} | units | {String} Index into OpenLayers.INCHES_PER_UNIT hashtable. Default is degrees |
Returns{Float} The corresponding resolution given passed-in scale and unit parameters.
getScaleFromResolutionOpenLayers.Util.getScaleFromResolution = function ( | resolution, | | units | ) |
|
Parametersresolution | {Float} | units | {String} Index into OpenLayers.INCHES_PER_UNIT hashtable. Default is degrees |
Returns{Float} The corresponding scale given passed-in resolution and unit parameters.
safeStopPropagationOpenLayers.Util.safeStopPropagation = function( | evt | ) |
|
Deprecated. This function has been deprecated. Please use directly OpenLayers.Event.stop() passing ‘true’ as the 2nd argument (preventDefault) Safely stop the propagation of an event without preventing the default browser action from occurring. Parameter
pagePositonCalculates the position of an element on the page. ParametersReturns:´ {Array} two item array, L value then T value.
isEquivalentUrlOpenLayers.Util.isEquivalentUrl = function( | url1, | | url2, | | options | ) |
|
Test two URLs for equivalence. Setting ‘ignoreCase’ allows for case-independent comparison. Comparison is based on- Protocol
- Host (evaluated without the port)
- Port (set ‘ignorePort80’ to ignore “80” values)
- Hash ( set ‘ignoreHash’ to disable)
- Pathname (for relative <-> absolute comparison)
- Arguments (so they can be out of order)
Parametersurl1 | {String} | url2 | {String} | options | {Object} Allows for customization of comparison: | ’ignoreCase’ | Default is True | ’ignorePort80’ | Default is True | ’ignoreHash’ | Default is True |
Returns{Boolean} Whether or not the two URLs are equivalent
createUrlObjectOpenLayers.Util.createUrlObject = function( | url, | | options | ) |
|
Parametersurl | {String} | options | {Object} A hash of options. Can be one of: ignoreCase: lowercase url, ignorePort80: don’t include explicit port if port is 80, ignoreHash: Don’t include part of url after the hash (#). |
Returns{Object} An object with separate url, a, port, host, and args parsed out and ready for comparison
removeTailOpenLayers.Util.removeTail = function( | url | ) |
|
Takes a url and removes everything after the ? and # Parametersurl | {String} The url to process |
Returns{String} The string with all queryString and Hash removed
getBrowserNameOpenLayers.Util.getBrowserName = function() |
Returns{String} A string which specifies which is the current browser in which we are running. Currently-supported browser detection and codes- ’opera’ -- Opera
- ’msie’ -- Internet Explorer
- ’safari’ -- Safari
- ’firefox’ -- FireFox
- ’mozilla’ -- Mozilla
If we are unable to property identify the browser, we return an empty string.
|