You are viewing an older version of Mapbox.js. Check out v3.3.1 for the latest.


Utility functions to work with the DOM tree, used by Leaflet internally.


Method Returns Description
get( <String or HTMLElement> id ) HTMLElement Returns an element with the given id if a string was passed, or just returns the element if it was passed directly.
getStyle( <HTMLElement> el, <String> style ) String Returns the value for a certain style attribute on an element, including computed values or values set through CSS.
getViewportOffset( <HTMLElement> el ) Point Returns the offset to the viewport for the requested element.
create( <String> tagName, <String> className, <HTMLElement> container? ) HTMLElement Creates an element with tagName, sets the className, and optionally appends it to container element.
disableTextSelection() - Makes sure text cannot be selected, for example during dragging.
enableTextSelection() - Makes text selection possible again.
hasClass( <HTMLElement> el, <String> name ) Boolean Returns true if the element class attribute contains name.
addClass( <HTMLElement> el, <String> name ) - Adds name to the element's class attribute.
removeClass( <HTMLElement> el, <String> name ) - Removes name from the element's class attribute.
setOpacity( <HTMLElement> el, <Number> value ) - Set the opacity of an element (including old IE support). Value must be from 0 to 1.
testProp( <String[]> props ) String or false Goes through the array of style names and returns the first name that is a valid style name for an element. If no such name is found, it returns false. Useful for vendor-prefixed styles like transform.
getTranslateString( <Point> point ) String Returns a CSS transform string to move an element by the offset provided in the given point. Uses 3D translate on WebKit for hardware-accelerated transforms and 2D on other browsers.
getScaleString( <Number> scale, <Point> origin ) String Returns a CSS transform string to scale an element (with the given scale origin).
setPosition( <HTMLElement> el, <Point> point, <Boolean> disable3D? ) - Sets the position of an element to coordinates specified by point, using CSS translate or top/left positioning depending on the browser (used by Leaflet internally to position its layers). Forces top/left positioning if disable3D is true.
getPosition( <HTMLElement> el ) Point Returns the coordinates of an element previously positioned with setPosition.


Property Type Description
TRANSITION String Vendor-prefixed transition style name (e.g. 'webkitTransition' for WebKit).
TRANSFORM String Vendor-prefixed transform style name.