Namespace: GeoHost

GeoHost

The elements that jxg-geoelements.js hangs on a host. A host is a map or a globe — anything that answers `addGeoLayer` — and every one of these works on either.
Source:

Methods

geoAnimate(path, optsopt) → {Object}

Fly a marker along a path. Returns a handle; stop() ends it. Without a marker one is created, so a single call is enough to see something move.
Parameters:
Name Type Attributes Description
path Object The path to run along.
opts Object <optional>
`marker` to reuse one; `duration` in ms; `loop`; `from` and `to` as fractions; `onFrame(marker, u)` and `onEnd(marker)`.
Source:
Returns:
`marker`, `stop()`, `restart()`. Where the host has no frame timer nothing is animated and a warning is given.
Type
Object

geoHandle(gp, attropt) → (nullable) {Object}

A draggable JSXGraph point bound to a geoPoint. This is the part a map library cannot offer: the handle is an ordinary JSXGraph point, so it can be constrained, measured, bound to a slider or used as a parent of any other construction — and the geographic position follows it. Dragging updates the geoPoint, which in turn refreshes every path and range that depends on it.
Parameters:
Name Type Attributes Description
gp Object The geoPoint to bind to.
attr Object <optional>
Attributes for the JSXGraph point.
Source:
Returns:
The handle: `point`, `setVisible(on)`. Null where the host has no board.
Type
Object

geoLabel(position, text, attropt) → (nullable) {Object}

A text at a geographic position. An ordinary JSXGraph text, moved to wherever its position now projects and hidden when that position goes behind the horizon — the same two jobs geoHandle does for a point.
Parameters:
Name Type Attributes Description
position Object | Array.<number> A geoPoint or a pair.
text string What to write.
attr Object <optional>
Attributes for the JSXGraph text.
Source:
Returns:
The label: `text`, `setText(v)`, `setVisible(on)`, `remove()`. Null where the host has no board, or can no longer place a position.
Type
Object

geoMarker(path, attropt) → {Object}

A marker riding on a path. Moving it only refreshes its own layer, so an animation does not touch the map or the globe geometry.
Parameters:
Name Type Attributes Description
path Object A geoPath to ride on.
attr Object <optional>
Style, plus `t` for where to start, from 0 to 1, and `size` for the radius in degrees.
Source:
Returns:
The marker: `t()`, `coords()`, `bearing()`, `setT(v)`, `setVisible(on)`.
Type
Object

geoNight(attropt) → {Object}

The night side, as a filled cap around the antisolar point. The terminator already exists as a line; this is the same circle used as a boundary instead of a stroke, which is why it needs no new geometry — only the winding has to be right, or the fill lands on the lit half.
Parameters:
Name Type Attributes Description
attr Object <optional>
Style, plus `date` for the moment; `blur` to grade the edge; `blurWidth` in degrees, held to what fits inside the cap; `blurSteps` for how many bands; and `blurSymmetric` to put the grading on both sides of the terminator rather than on the night side alone.
Source:
Returns:
The night: `setDate(d)`, `subsolar()`, `antisolar()`, `refresh()`, `setVisible(on)`.
Type
Object

geoOrbit(optsopt) → {Object}

A circular orbit with its ground track. Kepler for the shape, one constant for the rest: the period follows from the semi-major axis alone, T = 2*pi*sqrt(a^3/mu). The ground track is the same motion seen from a turning Earth, which is why it drifts west by one Earth rotation per revolution — the classic sine curve that never closes.
Parameters:
Name Type Attributes Description
opts Object <optional>
`altitude` in km above the surface, or `a` as the semi-major axis from the centre — anything at or below the surface is refused. `inclination` and `raan` in degrees, `phase` along the orbit, `samples` to fix the count.
Source:
Returns:
The orbit: `period()` in seconds, `axis()`, `altitude()`, `speed()` in km/s, `radii()`, `time()`, `position()`, `setTime(t)`, `setPhase(p)`, `showTrack(on)`.
Type
Object

geoPath(a, b, attropt) → {Object}

A path between two positions. Great circle by default; the distance and initial bearing come along, so the element is a measurement as much as a drawing.
Parameters:
Name Type Attributes Description
a Object | Array.<number> Start: a geoPoint or a [lon, lat] pair. Given a geoPoint, the path follows it.
b Object | Array.<number> End, likewise.
attr Object <optional>
Style, plus `mode` — "greatcircle" or "rhumb" — and `samples` to fix the count.
Source:
Returns:
The path: `points()`, `distance()` in km, `bearing()`, `at(t)`, `setMode(m)`, `refresh()`, `remove()`, and `animate(opts)`.
Type
Object

geoPoint(lon, lat, attropt) → {Object}

A position on the sphere, drawn as a small circle.
Parameters:
Name Type Attributes Description
lon number Longitude in degrees.
lat number Latitude in degrees.
attr Object <optional>
Style, plus `size` for the radius of the circle in degrees.
Source:
Returns:
The point: `lon()`, `lat()`, `coords()`, `moveTo(lon, lat)`, `setVisible(on)`, and a `followers` array that anything drawn from it registers with.
Type
Object

geoPolygon(points, attropt) → {Object}

A spherical polygon: any number of positions joined by great circles. geoTriangle is the three-cornered case with the angles named.
Parameters:
Name Type Attributes Description
points Array Three or more corners, each a geoPoint or a [lon, lat] pair. Given geoPoints, the polygon follows them.
attr Object <optional>
Style, plus `samples` and `tolerance`.
Source:
Returns:
The polygon: `area()` in square km, taken over the sphere rather than the drawing; `perimeter()` in km; `refresh()`, `setVisible(on)`, `remove()`.
Type
Object

geoRange(centre, km, attropt) → {Object}

Circles of constant distance around a position, in kilometres.
Parameters:
Name Type Attributes Description
centre Object | Array.<number> A geoPoint or a position.
km number | Array.<number> One radius or several, in kilometres. Anything past the antipode at 20015 km is refused.
attr Object <optional>
Style.
Source:
Returns:
The rings: `setRadii(v)`, `refresh()`, `setVisible(on)`, `remove()`.
Type
Object

geoRegion(ll, attropt) → {Object}

A region: a closed geographic ring with its true area. The area comes from the spherical excess, not from the drawing, so it does not depend on the projection the region was drawn in. Outline the same shape over Greenland and over Australia on a Mercator map and the two numbers will differ by a factor of three, while the shapes look alike — which is the whole argument about map projections in one gesture.
Parameters:
Name Type Attributes Description
ll Array.<Array.<number>> The ring, as [lon, lat] in degrees. Closed for you, and turned counter-clockwise if it was drawn the other way round.
attr Object <optional>
Style.
Source:
Returns:
The region: `area()` in square km, `perimeter()` in km, `centroid()`, `ring()`, `setRing(pts)`, `setVisible(on)`, `remove()`.
Type
Object

geoReticle(centre, attropt) → (nullable) {Object}

A target reticle: two concentric rings, four ticks and a centre dot. Everything is measured in degrees of arc rather than in screen units, so the same source serves both hosts — on the globe it sits on the surface and turns with it, on the map it goes through the projection like any other geometry, which is why it deforms towards the edges exactly as the map does.
Parameters:
Name Type Attributes Description
centre Object | Array.<number> A geoPoint or a pair.
attr Object <optional>
Style, plus `units` — "screen" for a fixed size in pixels, anything else for a size in degrees; `px` for that size; `farSide` to draw the half behind the globe.
Source:
Returns:
The reticle: `coords()`, `moveTo(lon, lat)`, `refresh()`, `setVisible(on)`, `remove()`.
Type
Object

geoSketch(optsopt) → (nullable) {Object}

Freehand marking, fed by JSXGraph's own sketch recording. The board collects the drag into board.sketches[0].dataX/dataY in user coordinates; all this does is read them on release and hand them to toGeo. The board must be created with sketches: { enabled: true }.
Parameters:
Name Type Attributes Description
opts Object <optional>
`style` for the region drawn; `minPoints` below which a drag is ignored; `onRegion(ring)`, called with the thinned ring of [lon, lat]; `keepStroke` to leave the raw stroke on screen. A 'geosketch' event carrying the same ring is fired on the board either way.
Source:
Returns:
`start()`, `stop()`, `isActive()`, `clear()` and `finish()`. The tool begins switched off, so a caller that wants to draw straight away has to call `start()`. Null where the host has no board.
Type
Object

geoTimeZone(offsetHours, attropt) → {Object}

A nominal time zone, highlighted, with its local time. The band is the 15-degree slice around the zone's meridian. A country's legal zone follows its border instead and can be offset by 30 or 45 minutes, so the two disagree by up to several hundred kilometres — which is exactly what makes the comparison worth drawing.
Parameters:
Name Type Attributes Description
offsetHours number The offset from UTC. Fractions are allowed: India is +5.5, Nepal +5.75.
attr Object <optional>
Style, plus `date` for the moment and `rule` for summer time — "none", "eu" or "us".
Source:
Returns:
The zone: `offset()`, `localTime()`, `label()`, `setOffset(h)`, `setDate(d)`, `setRule(r)`.
Type
Object

geoTrail(marker, attropt) → {Object}

A fading trail behind a marker. SVG cannot fade along a single stroke, so the trail is drawn as a few separate pieces of decreasing opacity. Four is enough to read as a gradient and cheap enough to redraw every frame.
Parameters:
Name Type Attributes Description
marker Object The marker to trail.
attr Object <optional>
Style, plus `length` as a fraction of the path.
Source:
Returns:
The trail: `refresh()`, `setVisible(on)`.
Type
Object

geoTriangle(a, b, c, attropt) → {Object}

A spherical triangle: three positions joined by great circles. The reason to build this in a geometry library rather than a map library: the angle sum is never 180 degrees. The excess over 180 is the area, in steradians — measure it, drag a corner, and the number moves with the shape. That is a statement about the sphere, not about cartography.
Parameters:
Name Type Attributes Description
a Object | Array.<number> First corner.
b Object | Array.<number> Second corner.
c Object | Array.<number> Third corner.
attr Object <optional>
Style, plus `samples` and `tolerance`.
Source:
Returns:
The triangle: `angles()`, `angleSum()`, `excess()` in degrees, `area()` in square km straight from the excess, `sides()` and `perimeter()` in km, `refresh()`, `setVisible(on)`, `remove()`. Corners in one place give zero rather than a negative area.
Type
Object