Class: scaleWidget

geo.gui. scaleWidget

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

Create a new instance of class geo.gui.scaleWidget.

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

Extends

Type Definitions

geo.gui.scaleWidget.specobject

Scale widget specification.

Properties:
Name Type Argument 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.

geo.gui.scaleWidget.unitobject

Scale widget unit specification.

Properties:
Name Type Argument 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.

Members

inherited idle

Getter for the idle state. Read only.

Properties:
Name Type Description
idle boolean

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

Methods

inherited addChild(child){this}

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

Name Type Description
child geo.object | Array.<geo.object>

A child object or array of child objects.

Returns:
Type Description
this

inherited addPromise(promise){this}

Add the promise here and also propagate up the scene tree.

Name Type Description
promise Promise

A promise object.

Returns:
Type Description
this

inherited canvas(val){HTMLElement|this}

Get/Set the canvas for the widget.

Name Type Description
val HTMLElement optional

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

Returns:
Type Description
HTMLElement | this If getting the canvas, return the current value; otherwise, return this widget.

Get an array of the child objects.

Returns:
Type Description
Array.<geo.object> A copy of the array of child objects.

inherited draw(arg){this}

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

Name Type Description
arg object

Options to pass to the child draw functions.

Returns:
Type Description
this

inherited geoIsOn(event, handler){boolean}

Report if an event handler is bound to this object.

Name Type 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:
Type Description
boolean true if any of the specified events are bound to the specified handler.

inherited geoOff(event, arg){this}

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

Name Type 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 Description
this

inherited geoOn(event, handler){this}

Bind an event handler to this object.

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 Description
this

inherited geoTrigger(event, args, childrenOnly){this}

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

Name Type 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 Description
this

inherited isInViewport(){boolean}

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

Returns:
Type Description
boolean True if the widget is within the viewport.

Return the layer associated with this widget.

Returns:
Type Description
geo.layer

inherited modified(){this}

Update the timestamp to the next global timestamp value.

Returns:
Type Description
this

inherited onIdle(handler){this}

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.

Name Type Description
handler function

A function taking no arguments.

Returns:
Type Description
this

options(arg1, arg2){object|this}

Set or get options.

Name Type 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:
Type Description
object | this If options are set, return the annotation, otherwise return the requested option or the set of options.

Get/set parent of the object.

Name Type Description
arg geo.sceneObject optional

The new parant or undefined to get the current parent.

Returns:
Type Description
this | geo.sceneObject

inherited parentCanvas(){HTMLElement}

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

Returns:
Type Description
HTMLElement The canvas of the widget's parent.

inherited position(pos, actualValue){geo.gui.widget.position|this}

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

Name Type 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:
Type Description
geo.gui.widget.position | this 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.

inherited removeChild(child){this}

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

Name Type Description
child geo.object | Array.<geo.object>

A child object or array of child objects.

Returns:
Type Description
this

inherited reposition(position){this}

Repositions a widget.

Name Type Description
position geo.gui.widget.position optional

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

Returns:
Type Description
this

inherited repositionEvent(){this}

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

Returns:
Type Description
this

inherited timestamp(){number}

Get time.

Returns:
Type Description
number The timestamp. This is 0 if the timestamp has never been modified.