scaleWidget

geo.gui. scaleWidget

new scaleWidget(arg) → {geo.gui.scaleWidget}

Description:
  • Create a new instance of class geo.gui.scaleWidget.

Source:
Parameters:
Name Type Description
arg geo.gui.scaleWidget.spec
Returns:
Type
geo.gui.scaleWidget

Extends

Members

idle

Description:
  • Getter for the idle state. Read only.

Source:
Inherited From:
Properties:
Name Type Description
idle boolean

true if the object is idle (onIdle would call a handler immediately).

Getter for the idle state. Read only.

(static) areaUnitsTable

Description:
  • The areaUnitsTable has predefined unit sets for a base unit of one square meter. Each entry is an array that must be in ascending order. This table can be passed to formatUnit.

Source:
Properties:
Name Type Description
areaUnitsTable object

The key names are the names of unit systems, such as si.

Properties
Name Type Description
unit Array.<geo.gui.scaleWidget.unitTableRecord>

A list of units within the unit system from smallest to largest.

The areaUnitsTable has predefined unit sets for a base unit of one square meter. Each entry is an array that must be in ascending order. This table can be passed to formatUnit.

(static) unitsTable

Description:
  • The unitsTable has predefined unit sets for a base unit of one meter. Each entry is an array that must be in ascending order. Use unicode in strings, not html entities. It makes it more reusable.

Source:
Properties:
Name Type Description
unitsTable object

The key names are the names of unit systems, such as si.

Properties
Name Type Description
unit Array.<geo.gui.scaleWidget.unitTableRecord>

A list of units within the unit system from smallest to largest.

The unitsTable has predefined unit sets for a base unit of one meter. Each entry is an array that must be in ascending order. Use unicode in strings, not html entities. It makes it more reusable.

Methods

addChild(child) → {this}

Description:
  • Add a child (or an array of children) to the object.

Source:
Inherited From:
Parameters:
Name Type Description
child geo.object | Array.<geo.object>

A child object or array of child objects.

Returns:
Type
this

addPromise(promise) → {this}

Description:
  • Add the promise here and also propagate up the scene tree.

Source:
Inherited From:
Parameters:
Name Type Description
promise Promise

A promise object.

Returns:
Type
this

canvas(valopt) → {HTMLElement|this}

Description:
  • Get/Set the canvas for the widget.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
val HTMLElement <optional>

If specified, set the canvas, otherwise get the canvas.

Returns:

If getting the canvas, return the current value; otherwise, return this widget.

Type
HTMLElement | this

children() → {Array.<geo.object>}

Description:
  • Get an array of the child objects.

Source:
Inherited From:
Returns:

A copy of the array of child objects.

Type
Array.<geo.object>

draw(arg) → {this}

Description:
  • Force redraw of a scene object, to be implemented by subclasses. Base class just calls draw of child objects.

Source:
Inherited From:
Parameters:
Name Type Description
arg object

Options to pass to the child draw functions.

Returns:
Type
this

geoIsOn(event, handleropt) → {boolean}

Description:
  • Report if an event handler is bound to this object.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
event string | Array.<string>

An event or list of events to check.

handler function <optional>

A function that might be bound. If undefined, this will report true if there is any handler for the specified event.

Returns:

true if any of the specified events are bound to the specified handler.

Type
boolean

geoOff(eventopt, argopt, nullable) → {this}

Description:
  • Remove handlers from one event or an array of events. If no event is provided all handlers will be removed.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
event string | Array.<string> <optional>

An event or a list of events from geo.event or defined by the user, or undefined to remove all events (in which case arg is ignored).

arg function | Array.<function()> <optional>
<nullable>

A function or array of functions to remove from the events or a falsy value to remove all handlers from the events.

Returns:
Type
this

geoOn(event, handler) → {this}

Description:
  • Bind an event handler to this object.

Source:
Inherited From:
Parameters:
Name Type Description
event string

An event from geo.event or a user-defined value.

handler function

A function that is called when event is triggered. The function is passed a geo.event object.

Returns:
Type
this

geoOnce(event, handler) → {function}

Description:
  • Bind an event handler to this object that will fire once and then deregister itself.

Source:
Inherited From:
Parameters:
Name Type Description
event string

An event from geo.event or a user-defined value.

handler function

A function that is called when event is triggered. The function is passed a geo.event object.

Returns:

The actual bound handler. This is a wrapper around the handler that was passed to the function.

Type
function

geoTrigger(event, args, childrenOnlyopt) → {this}

Description:
  • Trigger an event (or events) on this object and call all handlers.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
event string

The event to trigger.

args object

Arbitrary argument to pass to the handler.

childrenOnly boolean <optional>

If truthy, only propagate down the tree.

Returns:
Type
this

isInViewport() → {boolean}

Description:
  • Report if the top left of widget (or its current x, y position) is within the viewport.

Source:
Inherited From:
Returns:

True if the widget is within the viewport.

Type
boolean

layer() → {geo.layer}

Description:
  • Return the layer associated with this widget.

Source:
Inherited From:
Returns:
Type
geo.layer

modified() → {this}

Description:
  • Update the timestamp to the next global timestamp value.

Source:
Inherited From:
Returns:
Type
this

onIdle(handler) → {this}

Description:
  • Bind a handler that will be called one time when all internal promises are resolved. If there are no outstanding promises, this is invoked synchronously.

Source:
Inherited From:
Parameters:
Name Type Description
handler function

A function taking no arguments.

Returns:
Type
this

options(arg1opt, arg2opt) → {object|this}

Description:
  • Get or set options.

Source:
Parameters:
Name Type Attributes Description
arg1 string | object <optional>

If undefined, return the options object. If a string, either set or return the option of that name. If an object, update the options with the object's values.

arg2 object <optional>

If arg1 is a string and this is defined, set the option to this value.

Returns:

If options are set, return the annotation, otherwise return the requested option or the set of options.

Type
object | this

parent(argopt) → {this|geo.sceneObject}

Description:
  • Get/set parent of the object.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
arg geo.sceneObject <optional>

The new parent or undefined to get the current parent.

Returns:
Type
this | geo.sceneObject

parentCanvas() → {HTMLElement}

Description:
  • Get the parent canvas (top level widgets define their layer as their parent canvas).

Source:
Inherited From:
Returns:

The canvas of the widget's parent.

Type
HTMLElement

position(posopt, actualValueopt) → {geo.gui.widget.position|this}

Description:
  • Get or set the CSS positioning that a widget should be placed at.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
pos geo.gui.widget.position <optional>

If unspecified, return the current position. Otherwise, set the current position.

actualValue boolean <optional>

If getting the position, if this is truthy, always return the stored value, not a value adjusted for display.

Returns:

Either the position or the widget instance. If this is the position and actualValue is falsy, positions that specify an explicit x and y parameter will be converted to a value that can be used by the display css.

Type
geo.gui.widget.position | this

removeChild(child) → {this}

Description:
  • Remove a child (or array of children) from the object.

Source:
Inherited From:
Parameters:
Name Type Description
child geo.object | Array.<geo.object>

A child object or array of child objects.

Returns:
Type
this

removePromise(promise) → {this}

Description:
  • Remove the promise here and also propagate up the scene tree.

Source:
Inherited From:
Parameters:
Name Type Description
promise Promise

A promise object.

Returns:
Type
this

reposition(positionopt) → {this}

Description:
  • Repositions a widget.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
position geo.gui.widget.position <optional>

The new position for the widget. undefined uses the stored position value.

Returns:
Type
this

repositionEvent() → {this}

Description:
  • If the position is based on map coordinates, this gets called when the map is panned to resposition the widget.

Source:
Inherited From:
Returns:
Type
this

timestamp() → {number}

Description:
  • Get time.

Source:
Inherited From:
Returns:

The timestamp. This is 0 if the timestamp has never been modified.

Type
number

(static) formatUnit(val, unitopt, tableopt, digitsopt) → {string}

Description:
  • Format a unit with a specified number of significant figures. Given a value in base units, such as meters, this will return a string with appropriate units. For instance, formatUnit(0.345) will return 345 mm.

Source:
Parameters:
Name Type Attributes Default Description
val number

The value. A length or area in base units. With the default unit table, this is in meters. With the areaUnitsTable, this is square meters.

unit string | Array.<object> <optional>
'si'

The name of the unit system or a unit table.

table object <optional>
unitTable

The table of the unit system. Ignored if unit is a unit table.

digits number <optional>
3

The minimum number of significant figures.

Returns:

A formatted string or undefined.

Type
string

Type Definitions

spec

Description:
  • Scale widget specification.

Source:
Properties:
Name Type Attributes Default Description
scale number <optional>
1

A scale applied to the map gcs units to convert to the scale units.

maxWidth number <optional>
200

The maximum width of the scale in pixels. For horizontal scales (orientation is top or bottom) this is the maximum length of the scale bar. For vertical scales, this is the width available for the scale text.

maxHeight number <optional>

The maximum height of the scale in pixels. For vertical scales (orientation is left or right) this is the maximum length of the scale bar. For horizontal scales, this is the height available for the scale text. Default is 200 for vertical scales, 20 for horizontal scales.

orientation string <optional>
'bottom'

One of left, right, top, or bottom. The scale text is placed in that location relative to the scale bar.

strokeWidth number <optional>
2

The width of the ticks and scale bar in pixels.

tickLength number <optional>
10

The length of the end ticks in pixels.

units string | Array.<geo.gui.scaleWidget.unit> <optional>
'si'

One of either 'si' or 'miles' or an array of units in ascending order. See the UnitsTable for examples.

distance function <optional>

The function used to compute the length of the scale bar. This defaults to transform.sphericalDistance for all maps except those with a gcs of '+proj=longlat +axis=enu', where math.sqrt(util.distance2dSquared(pt1, pt2)) is used instead.

Scale widget specification.

Type:
  • object

unit

Description:
  • Scale widget unit specification.

Source:
Properties:
Name Type Attributes Default Description
unit string

Display name for the unit.

scale number

Scale for 1 unit in the current system.

minimum number <optional>
1

Minimum value where this applies after scaling. This can be used to handle singular and plural words (e.g., [{units: 'meter', scale: 1}, {units: 'meters', scale: 1, minimum: 1.5}])

basis number <optional>
10

The basis for the multiples value.

multiples Array.<object> <optional>

A list of objects in ascending value order that determine what round values are displayed.

Properties
Name Type Description
multiple number

The value that is selected for display.

digit number

The number of significant digits in mutliple.

Scale widget unit specification.

Type:
  • object

unitTableRecord

Description:
  • For a unit table, the records are ordered smallest scale to largest scale. The smallest unit can be repeated to have different rounding behavior for values less than 1 and values greater than or equal to 1.

Source:
Properties:
Name Type Attributes Default Description
unit string

The display name of the unit.

scale number

The size of the unit in base unit.

basis number <optional>
10

The number of units in the next greater unit if not a power of 10.

multiples Array.<object> <optional>

A list of multiplier values to round to when rounding is used. The list should probably include a multiple of 1. Default is 1, 1.5, 2, 3, 5, 8.

Properties
Name Type Description
multiple number

A factor to round to.

digit number

The number of digits to preserve when rounding.

For a unit table, the records are ordered smallest scale to largest scale. The smallest unit can be repeated to have different rounding behavior for values less than 1 and values greater than or equal to 1.

Type:
  • object