Util

Summary
Util
Functions and Properties
getElementThis is the old $() from prototype
isElementA cross-browser implementation of “e instanceof Element”.
isArrayTests that the provided object is an array.
removeItemRemove an object from an array.
indexOfSeems to exist already in FF, but not in MOZ.
modifyDOMElementModifies many properties of a DOM element all at once.
createDivCreates a new div and optionally set some standard attributes.
createImageCreates an img element with specific attribute values.
IMAGE_RELOAD_ATTEMPTS{Integer} How many times should we try to reload an image before giving up? 
makeInitOnceGetterReturns a function that initializes a value once, and then just returns the value on subsequent calls
alphaHackChecks whether it’s necessary (and possible) to use the png alpha hack which allows alpha transparency for png images under Internet Explorer.
modifyAlphaImageDiv
createAlphaImageDiv
upperCaseObjectCreates 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.
applyDefaultsTakes an object and copies any properties that don’t exist from another properties, by analogy with ALKMaps.Util.extend() from Prototype.js.
getParameterString
urlAppendAppends a parameter string to a url.
getImagesLocation{String} The fully formatted image location string
getImageLocation{String} The fully formatted location string for a specified image
TryExecute functions until one of them doesn’t throw an error.
getXmlNodeValue
mouseLeft
precision{Number} The number of significant digits to retain to avoid floating point precision errors.
toFloatConvenience method to cast an object to a Number, rounded to the desired floating point precision.
rad
deg
VincentyConstants{Object} Constants for Vincenty functions.
distVincentyGiven two objects representing points with geographic coordinates, this calculates the distance between those points on the surface of an ellipsoid.
destinationVincentyCalculate destination point given start point lat/long (numeric degrees), bearing (numeric degrees) & distance (in m).
getParametersParse the parameters from a URL or from the current page itself into a JavaScript Object.
createUniqueIDCreate a unique identifier for this session.
Constants
INCHES_PER_UNIT{Object} Constant inches per unit -- borrowed from MapServer mapscale.c derivation of nautical miles from https://en.wikipedia.org/wiki/Nautical_mile Includes the full set of units supported by CS-MAP (http://trac.osgeo.org/csmap/) and PROJ.4 (https://proj.org/) The hardcoded table is maintain in a CS-MAP source code module named CSdataU.c The hardcoded table of PROJ.4 units are in pj_units.c.
DOTS_PER_INCH{Integer} 72 (A sensible default)
Functions
normalizeScale
getResolutionFromScale
getScaleFromResolution
pagePositionCalculates the position of an element on the page getViewportElementReturns die viewport element of the document.
isEquivalentUrlTest two URLs for equivalence.
createUrlObject
removeTailTakes a url and removes everything after the ?
Constants
IS_GECKO{Boolean} True if the userAgent reports the browser to use the Gecko engine
CANVAS_SUPPORTED{Boolean} True if canvas 2d is supported.
BROWSER_NAME{String} A substring of the navigator.userAgent property.
Functions
getBrowserName{String} A string which specifies which is the current browser in which we are running.
getRenderedDimensionsRenders the contentHTML offscreen to determine actual dimensions for popup sizing.
getScrollbarWidthThis function has been modified by the ALKMaps from the original version, written by Matthew Eernisse and released under the Apache 2 license here:
getFormattedLonLatThis function will return latitude or longitude value formatted as
buildTableCellDeprecated.
buildTableOrRowDeprecated.
convertToStringArrayConvert string to string array.
getRegionDetermines the correct region number for the corresponding enumeration string, and defaults to NA(4).
getDataSetDetermines if the value of the dataset passed in is valid, and if not defaults to Current.
getDatasetFromRegionReturns the dataset corresponding to the given region.
rgbToHexConvert RGB value to HEX
hexToRgbConverts hex to rgb.
buildLabelElementThis method can be used to build HTML lable element.
buildSelectElementBuild HTML Select element with options.
getScriptSrcGets the source path from the HTML script tag of the given file.
getAPIKeyGets the user given API key from either the script query string or the ALKMaps property.
getYearGets the current year.
enableContextMenuEnables the default right-click context menu of the provided div;
disableContextMenuDisables the default right-click context menu of the provided div;

Functions and Properties

getElement

ALKMaps.Util.getElement = function ()

This is the old $() from prototype

Parameters

e{String or DOMElement or Window}

Returns

{Array(DOMElement) or DOMElement}

isElement

ALKMaps.Util.isElement = function (o)

A cross-browser implementation of “e instanceof Element”.

Parameters

o{Object} The object to test.

Returns

{Boolean}

isArray

ALKMaps.Util.isArray = function (a)

Tests that the provided object is an array.  This test handles the cross-IFRAME case not caught by “a instanceof Array” and should be used instead.

Parameters

a{Object} the object test.

Returns

{Boolean} true if the object is an array.

removeItem

ALKMaps.Util.removeItem = function (array,
item)

Remove an object from an array.  Iterates through the array to find the item, then removes it.

Parameters

array{Array}
item{Object}

Returns

{Array} A reference to the array

indexOf

ALKMaps.Util.indexOf = function (array,
obj)

Seems to exist already in FF, but not in MOZ.

Parameters

array{Array}
obj{*}

Returns

{Integer} The index at, which the first object was found in the array.  If not found, returns -1.

modifyDOMElement

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

Parameters

element{DOMElement} DOM element to modify.
id{String} The element id attribute to set.
px{<ALKMaps.Pixel>|Object} The element left and top position, ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties.
sz{<ALKMaps.Size>|Object} The element width and height, ALKMaps.Size or an object with a ‘w’ and ‘h’ properties.
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)

createDiv

ALKMaps.Util.createDiv = function (id,
px,
sz,
imgURL,
position,
border,
overflow,
opacity)

Creates 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.  Note - zIndex is NOT set on the resulting div.

Parameters

id{String} An identifier for this element.  If no id is passed an identifier will be created automatically.
px{<ALKMaps.Pixel>|Object} The element left and top position, ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties.
sz{<ALKMaps.Size>|Object} The element width and height, ALKMaps.Size or an object with a ‘w’ and ‘h’ properties.
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.

createImage

ALKMaps.Util.createImage = function (id,
px,
sz,
imgURL,
position,
border,
opacity,
delayDisplay)

Creates an img element with specific attribute values.

Parameters

id{String} The id field for the img.  If none assigned one will be automatically generated.
px{<ALKMaps.Pixel>|Object} The element left and top position, ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties.
sz{<ALKMaps.Size>|Object} The element width and height, ALKMaps.Size or an object with a ‘w’ and ‘h’ properties.
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.
opacity{Float} Fractional value (0.0 - 1.0)
delayDisplay{Boolean} If true waits until the image has been loaded.

Returns

{DOMElement} A DOM Image created with the specified attributes.

IMAGE_RELOAD_ATTEMPTS

{Integer} How many times should we try to reload an image before giving up?  Default is 0

makeInitOnceGetter

ALKMaps.Util.makeInitOnceGetter = function (object,
funcName,
initFunc)

Returns a function that initializes a value once, and then just returns the value on subsequent calls

Returns

{Function}

alphaHack

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 the png alpha hack is necessary and possible, false otherwise.

modifyAlphaImageDiv

ALKMaps.Util.modifyAlphaImageDiv = function (div,
id,
px,
sz,
imgURL,
position,
border,
sizing,
opacity)

Parameters

div{DOMElement} Div containing Alpha-adjusted Image
id{String}
px{<ALKMaps.Pixel>|Object} ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties.
sz{<ALKMaps.Size>|Object} ALKMaps.Size or an object with a ‘w’ and ‘h’ properties.
imgURL{String}
position{String}
border{String}
sizing{String} ‘crop’, ‘scale’, or ‘image’.  Default is “scale”
opacity{Float} Fractional value (0.0 - 1.0)

createAlphaImageDiv

ALKMaps.Util.createAlphaImageDiv = function (id,
px,
sz,
imgURL,
position,
border,
sizing,
opacity,
delayDisplay)

Parameters

id{String}
px{<ALKMaps.Pixel>|Object} ALKMaps.Pixel or an object with a ‘x’ and ‘y’ properties.
sz{<ALKMaps.Size>|Object} ALKMaps.Size or an object with a ‘w’ and ‘h’ properties.
imgURL{String}
position{String}
border{String}
sizing{String} ‘crop’, ‘scale’, or ‘image’.  Default is “scale”
opacity{Float} Fractional value (0.0 - 1.0)
delayDisplay{Boolean} If true waits until the image has been loaded.

Returns

{DOMElement} A DOM Div created with a DOM Image inside it.  If the hack is needed for transparency in IE, it is added.

upperCaseObject

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

Parameters

object{Object}

Returns

{Object} A new Object with all the same keys but uppercased

applyDefaults

ALKMaps.Util.applyDefaults = function (to,
from)

Takes an object and copies any properties that don’t exist from another properties, by analogy with ALKMaps.Util.extend() from Prototype.js.

Parameters

to{Object} The destination object.
from{Object} The source object.  Any properties of this object that are undefined in the to object will be set on the to object.

Returns

{Object} A reference to the to object.  Note that the to argument is modified in place and returned by this function.

getParameterString

ALKMaps.Util.getParameterString = function (params)

Parameters

params{Object}

Returns

{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-separated list of values (foo,bar) instead of being URL escaped (foo%3Abar).

urlAppend

ALKMaps.Util.urlAppend = function (url,
paramStr)

Appends a parameter string to a url.  This function includes the logic for using the appropriate character (none, & or ?) to append to the url before appending the param string.

Parameters

url{String} The url to append to
paramStr{String} The param string to append

Returns

{String} The new url

getImagesLocation

Returns

{String} The fully formatted image location string

getImageLocation

ALKMaps.Util.getImageLocation = function (image)

Returns

{String} The fully formatted location string for a specified image

Try

ALKMaps.Util.Try = function ()

Execute functions until one of them doesn’t throw an error.  Capitalized because “try” is a reserved word in JavaScript.

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.

getXmlNodeValue

ALKMaps.Util.getXmlNodeValue = function (node)

Parameters

node{XMLNode}

Returns

{String} The text value of the given node, without breaking in firefox or IE

mouseLeft

ALKMaps.Util.mouseLeft = function (evt,
div)

Parameters

evt{Event}
div{HTMLDivElement}

Returns

{Boolean}

precision

{Number} The number of significant digits to retain to avoid floating point precision errors.

We use 14 as a “safe” default because, although IEEE 754 double floats (standard on most modern operating systems) support up to about 16 significant digits, 14 significant digits are sufficient to represent sub-millimeter accuracy in any coordinate system that anyone is likely to use with ALKMaps.

If DEFAULT_PRECISION is set to 0, the original non-truncating behavior of ALKMaps <2.8 is preserved.  Be aware that this will cause problems with certain projections, e.g. spherical Mercator.

toFloat

ALKMaps.Util.toFloat = function (number,
precision)

Convenience method to cast an object to a Number, rounded to the desired floating point precision.

Parameters

number{Number} The number to cast and round.
precision{Number} An integer suitable for use with Number.toPrecision().  Defaults to ALKMaps.Util.DEFAULT_PRECISION.  If set to 0, no rounding is performed.

Returns

{Number} The cast, rounded number.

rad

ALKMaps.Util.rad = function (x)

Parameters

x{Float}

Returns

{Float}

deg

ALKMaps.Util.deg = function (x)

Parameters

x{Float}

Returns

{Float}

VincentyConstants

{Object} Constants for Vincenty functions.

distVincenty

ALKMaps.Util.distVincenty = function (p1,
p2)

Given two objects representing points with geographic coordinates, this calculates the distance between those points on the surface of an ellipsoid.

Parameters

p1{ALKMaps.LonLat} (or any object with both .lat, .lon properties)
p2{ALKMaps.LonLat} (or any object with both .lat, .lon properties)

Returns

{Float} The distance (in km) between the two input points as measured on an ellipsoid.  Note that the input point objects must be in geographic coordinates (decimal degrees) and the return distance is in kilometers.

destinationVincenty

ALKMaps.Util.destinationVincenty = function (lonlat,
brng,
dist)

Calculate destination point given start point lat/long (numeric degrees), bearing (numeric degrees) & distance (in m).  Adapted from Chris Veness work, see https://www.movable-type.co.uk/scripts/latlong-vincenty-direct.html

Parameters

lonlat{ALKMaps.LonLat} (or any object with both .lat, .lon properties) The start point.
brng{Float} The bearing (degrees).
dist{Float} The ground distance (meters).

Returns

{ALKMaps.LonLat} The destination point.

getParameters

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

Parameters

url{String} Optional url used to extract the query string.  If url is null or is not supplied, query string is taken from the page location.

Returns

{Object} An object of key/value pairs from the query string.

createUniqueID

Create a unique identifier for this session.  Each time this function is called, a counter is incremented.  The return will be the optional prefix (defaults to “id_”) appended with the counter value.

Parameters

prefix {String} Optional string to prefix unique id.  Default is “id_”.

Returns

{String} A unique id string, built on the passed in prefix.

Constants

INCHES_PER_UNIT

{Object} Constant inches per unit -- borrowed from MapServer mapscale.c derivation of nautical miles from https://en.wikipedia.org/wiki/Nautical_mile Includes the full set of units supported by CS-MAP (http://trac.osgeo.org/csmap/) and PROJ.4 (https://proj.org/) The hardcoded table is maintain in a CS-MAP source code module named CSdataU.c The hardcoded table of PROJ.4 units are in pj_units.c.

DOTS_PER_INCH

{Integer} 72 (A sensible default)

Functions

normalizeScale

ALKMaps.Util.normalizeScale = function (scale)

Parameters

scale{float}

Returns

{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

getResolutionFromScale

ALKMaps.Util.getResolutionFromScale = function (scale,
units)

Parameters

scale{Float}
units{String} Index into ALKMaps.INCHES_PER_UNIT hashtable.  Default is degrees

Returns

{Float} The corresponding resolution given passed-in scale and unit parameters.  If the given scale is falsey, the returned resolution will be undefined.

getScaleFromResolution

ALKMaps.Util.getScaleFromResolution = function (resolution,
units)

Parameters

resolution{Float}
units{String} Index into ALKMaps.INCHES_PER_UNIT hashtable.  Default is degrees

Returns

{Float} The corresponding scale given passed-in resolution and unit parameters.

pagePosition

ALKMaps.Util.pagePosition = function (forElement)

Calculates the position of an element on the page

getViewportElement

Returns die viewport element of the document.  The viewport element is usually document.documentElement, except in IE,where it is either document.body or document.documentElement, depending on the document’s compatibility mode

isEquivalentUrl

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

Parameters

url1{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

createUrlObject

ALKMaps.Util.createUrlObject = function (url,
options)

Parameters

url{String}
options{Object} A hash of options.

Valid options

ignoreCase{Boolean} lowercase url,
ignorePort80{Boolean} don’t include explicit port if port is 80,
ignoreHash{Boolean} 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

removeTail

ALKMaps.Util.removeTail = function (url)

Takes a url and removes everything after the ? and #

Parameters

url{String} The url to process

Returns

{String} The string with all queryString and Hash removed

Constants

IS_GECKO

{Boolean} True if the userAgent reports the browser to use the Gecko engine

CANVAS_SUPPORTED

{Boolean} True if canvas 2d is supported.

BROWSER_NAME

{String} A substring of the navigator.userAgent property.  Depending on the userAgent property, this will be the empty string or one of the following:

  • ”opera” -- Opera
  • ”msie” -- Internet Explorer 10 or older
  • ”safari” -- Safari
  • ”firefox” -- Firefox
  • ”mozilla” -- Mozilla

Functions

getBrowserName

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

getRenderedDimensions

ALKMaps.Util.getRenderedDimensions = function (contentHTML,
size,
options)

Renders the contentHTML offscreen to determine actual dimensions for popup sizing.  As we need layout to determine dimensions the content is rendered -9999px to the left and absolute to ensure the scrollbars do not flicker

Parameters

contentHTML size - {ALKMaps.Size} If either the ‘w’ or ‘h’ properties is specified, we fix that dimension of the div to be measured.  This is useful in the case where we have a limit in one dimension and must therefore measure the flow in the other dimension. options - {Object}

Allowed Options

displayClass{String} Optional parameter.  A CSS class name(s) string to provide the CSS context of the rendered content.
containerElement{DOMElement} Optional parameter.  Insert the HTML to this node instead of the body root when calculating dimensions.

Returns

{ALKMaps.Size}

getScrollbarWidth

ALKMaps.Util.getScrollbarWidth = function ()

This function has been modified by the ALKMaps from the original version, written by Matthew Eernisse and released under the Apache 2 license here:

http://www.fleegix.org/articles/2006/05/30/getting-the-scrollbar-width-in-pixels

It has been modified simply to cache its value, since it is physically impossible that this code could ever run in more than one browser at once.

Returns

{Integer}

getFormattedLonLat

ALKMaps.Util.getFormattedLonLat = function (coordinate,
axis,
dmsOption)

This function will return latitude or longitude value formatted as

Parameters

coordinate{Float} the coordinate value to be formatted
axis{String} value of either ‘lat’ or ‘lon’ to indicate which axis is to to be formatted (default = lat)
dmsOption{String} specify the precision of the output can be one of: ‘dms’ show degrees minutes and seconds ‘dm’ show only degrees and minutes ‘d’ show only degrees

Returns

{String} the coordinate value formatted as a string

buildTableCell

ALKMaps.Util.buildTableCell = function (tag,
content,
colspan,
cssClass)

Deprecated.  Build table cell.

Parameters

tag{String} TD or TH
content{Array(String)}
cssClass{String} colspan = {Number}

Returns

{DOMElement}

buildTableOrRow

ALKMaps.Util.buildTableOrRow = function (tag,
trs,
cssClass,
id)

Deprecated.  Build table or table row.

Parameters

tag{String} TR or TABLE
trs{Array(String)}
cssClass{String} id = {String}

Returns

{DOMElement}

convertToStringArray

ALKMaps.Util.convertToStringArray = function (drawers)

Convert string to string array.

Parameters

drawers{String} string separated by comma.

Returns

{Array(String)}

getRegion

ALKMaps.Util.getRegion = function (region)

Determines the correct region number for the corresponding enumeration string, and defaults to NA(4).

Parameters

region{String or Number}

Returns

{Number} The region number.

getDataSet

ALKMaps.Util.getDataSet = function (dataset)

Determines if the value of the dataset passed in is valid, and if not defaults to Current.

Parameters

dataset{String or Number}

Returns

{String or Number} The dataset.

getDatasetFromRegion

ALKMaps.Util.getDatasetFromRegion = function (region)

Returns the dataset corresponding to the given region.  If no match is found, returns Current as the default.

Parameters

region{String or Number}

Returns

{String} The dataset.

rgbToHex

ALKMaps.Util.rgbToHex = function (r,
g,
b)

Convert RGB value to HEX

Parameters

r{Number}

Returns

{String}

hexToRgb

ALKMaps.Util.hexToRgb = function (hex)

Converts hex to rgb.

Parameters

hex{String}

Returns

{Array(Number)}

buildLabelElement

ALKMaps.Util.buildLabelElement = function (input)

This method can be used to build HTML lable element.

Parameters

input{Object}

Valid input

id{String}
cssClass{String}
text{String}

Returns

{DOMElement}

buildSelectElement

ALKMaps.Util.buildSelectElement = function (input)

Build HTML Select element with options.

Parameters

input{Object}

Valid input

id{String}
cssClass{String}
optTexts{Array}
optValues{Array}
selectedValue{String}

Returns

{DOMElement}

getScriptSrc

ALKMaps.Util.getScriptSrc = function (fileName)

Gets the source path from the HTML script tag of the given file.

Parameters

filename{String} Name of the script file.
var source = L.ALKMaps.Util.getScriptSrc("myScript.js");

Returns

{String} The script source path.

getAPIKey

Gets the user given API key from either the script query string or the ALKMaps property.

var key = L.ALKMaps.Util.getAPIKey();

Parameters

isInitMap{Boolean} or {Date}

Returns

{String} The API key.

getYear

ALKMaps.Util.getYear = function ()

Gets the current year.

var year = ALKMaps.Util.getYear();

Returns

{Integer} The current 4 digit year.  2014

enableContextMenu

ALKMaps.Util.enableContextMenu = function (div)

Enables the default right-click context menu of the provided div;

disableContextMenu

ALKMaps.Util.disableContextMenu = function (div)

Disables the default right-click context menu of the provided div;

ALKMaps.Util.getElement = function ()
This is the old $() from prototype
ALKMaps.Util.isElement = function (o)
A cross-browser implementation of “e instanceof Element”.
ALKMaps.Util.isArray = function (a)
Tests that the provided object is an array.
ALKMaps.Util.removeItem = function (array,
item)
Remove an object from an array.
ALKMaps.Util.indexOf = function (array,
obj)
Seems to exist already in FF, but not in MOZ.
ALKMaps.Util.modifyDOMElement = function (element,
id,
px,
sz,
position,
border,
overflow,
opacity)
Modifies many properties of a DOM element all at once.
ALKMaps.Util.createDiv = function (id,
px,
sz,
imgURL,
position,
border,
overflow,
opacity)
Creates a new div and optionally set some standard attributes.
ALKMaps.Util.createImage = function (id,
px,
sz,
imgURL,
position,
border,
opacity,
delayDisplay)
Creates an img element with specific attribute values.
ALKMaps.Util.makeInitOnceGetter = function (object,
funcName,
initFunc)
Returns a function that initializes a value once, and then just returns the value on subsequent calls
ALKMaps.Util.modifyAlphaImageDiv = function (div,
id,
px,
sz,
imgURL,
position,
border,
sizing,
opacity)
ALKMaps.Util.createAlphaImageDiv = function (id,
px,
sz,
imgURL,
position,
border,
sizing,
opacity,
delayDisplay)
ALKMaps.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.
ALKMaps.Util.applyDefaults = function (to,
from)
Takes an object and copies any properties that don’t exist from another properties, by analogy with ALKMaps.Util.extend() from Prototype.js.
ALKMaps.Util.getParameterString = function (params)
ALKMaps.Util.urlAppend = function (url,
paramStr)
Appends a parameter string to a url.
ALKMaps.Util.getImageLocation = function (image)
{String} The fully formatted location string for a specified image
ALKMaps.Util.Try = function ()
Execute functions until one of them doesn’t throw an error.
ALKMaps.Util.getXmlNodeValue = function (node)
ALKMaps.Util.mouseLeft = function (evt,
div)
ALKMaps.Util.toFloat = function (number,
precision)
Convenience method to cast an object to a Number, rounded to the desired floating point precision.
ALKMaps.Util.rad = function (x)
ALKMaps.Util.deg = function (x)
ALKMaps.Util.distVincenty = function (p1,
p2)
Given two objects representing points with geographic coordinates, this calculates the distance between those points on the surface of an ellipsoid.
ALKMaps.Util.destinationVincenty = function (lonlat,
brng,
dist)
Calculate destination point given start point lat/long (numeric degrees), bearing (numeric degrees) & distance (in m).
ALKMaps.Util.getParameters = function (url)
Parse the parameters from a URL or from the current page itself into a JavaScript Object.
ALKMaps.Util.normalizeScale = function (scale)
ALKMaps.Util.getResolutionFromScale = function (scale,
units)
ALKMaps.Util.getScaleFromResolution = function (resolution,
units)
ALKMaps.Util.pagePosition = function (forElement)
Calculates the position of an element on the page
ALKMaps.Util.isEquivalentUrl = function (url1,
url2,
options)
Test two URLs for equivalence.
ALKMaps.Util.createUrlObject = function (url,
options)
ALKMaps.Util.removeTail = function (url)
Takes a url and removes everything after the ?
ALKMaps.Util.getBrowserName = function ()
{String} A string which specifies which is the current browser in which we are running.
ALKMaps.Util.getRenderedDimensions = function (contentHTML,
size,
options)
Renders the contentHTML offscreen to determine actual dimensions for popup sizing.
ALKMaps.Util.getScrollbarWidth = function ()
This function has been modified by the ALKMaps from the original version, written by Matthew Eernisse and released under the Apache 2 license here:
ALKMaps.Util.getFormattedLonLat = function (coordinate,
axis,
dmsOption)
This function will return latitude or longitude value formatted as
ALKMaps.Util.buildTableCell = function (tag,
content,
colspan,
cssClass)
Deprecated.
ALKMaps.Util.buildTableOrRow = function (tag,
trs,
cssClass,
id)
Deprecated.
ALKMaps.Util.convertToStringArray = function (drawers)
Convert string to string array.
ALKMaps.Util.getRegion = function (region)
Determines the correct region number for the corresponding enumeration string, and defaults to NA(4).
ALKMaps.Util.getDataSet = function (dataset)
Determines if the value of the dataset passed in is valid, and if not defaults to Current.
ALKMaps.Util.getDatasetFromRegion = function (region)
Returns the dataset corresponding to the given region.
ALKMaps.Util.rgbToHex = function (r,
g,
b)
Convert RGB value to HEX
ALKMaps.Util.hexToRgb = function (hex)
Converts hex to rgb.
ALKMaps.Util.buildLabelElement = function (input)
This method can be used to build HTML lable element.
ALKMaps.Util.buildSelectElement = function (input)
Build HTML Select element with options.
ALKMaps.Util.getScriptSrc = function (fileName)
Gets the source path from the HTML script tag of the given file.
ALKMaps.Util.getYear = function ()
Gets the current year.
ALKMaps.Util.enableContextMenu = function (div)
Enables the default right-click context menu of the provided div;
ALKMaps.Util.disableContextMenu = function (div)
Disables the default right-click context menu of the provided div;
This class represents a longitude and latitude pair
Instances of this class represent a width/height pair