Skip to main content

@jetblack/map

Component Interfaces

Context Interfaces

Other Interfaces

Component Variables

Context Variables

Other Variables

Tile Provider Variables

Component Functions

Other Functions

Tile Provider Functions

Type Aliases

Point

Ƭ Point: Object

A point in the Cartesian coordinate system.

Type declaration

NameTypeDescription
xnumberA point on the horizontal axis.
ynumberA point on the vertical axis

Defined in

types.ts:22

Component Variables

Map

Const Map: ForwardRefExoticComponent<MapProps & RefAttributes<HTMLDivElement>>

Render a map.

param The props.

returns A map.

Defined in

components/Map.tsx:52


Context Variables

MapContext

Const MapContext: Context<MapContextProps>

The map context.

Defined in

components/MapContext.ts:30


Other Variables

CLASS_NAMES

Const CLASS_NAMES: Object

Type declaration

NameType
clickablestring
draggablestring
primarystring
zoomablestring

Defined in

constants.ts:56


Tile Provider Variables

osmTileProvider

Const osmTileProvider: TileProvider

A tile provider for Open Street Map.

Defined in

components/TileProviders.tsx:8

Component Functions

AttributionLayer

AttributionLayer(): Element

Render the attribution layer.

Returns

Element

Defined in

components/AttributionLayer.tsx:15


ImageTile

ImageTile(props): Element

Render an image tile.

internal

Parameters

NameTypeDescription
propsImageTilePropsThe props.

Returns

Element

An image tile.

Defined in

components/ImageTile.tsx:41


Marker

Marker(props): Element

Render a marker component.

Parameters

NameTypeDescription
propsMarkerPropsThe props.

Returns

Element

A map.

Defined in

components/Marker.tsx:37


OverlayLayer

OverlayLayer(props): Element

Render an overlay layer.

Parameters

NameTypeDescription
propsOverlayLayerPropsThe props.

Returns

Element

A map.

Defined in

components/OverlayLayer.tsx:33


Pin

Pin<T>(props): Element

Render a pin.

Type parameters

NameType
Tunknown

Parameters

NameTypeDescription
propsPinProps<T>The props.

Returns

Element

A pin at the point.

Defined in

components/Pin.tsx:49


Popup(props): Element

Render a popup.

The popup will attempt to stay inside the map space by checking if the point is in the left/right and top/bottom of the screen and positioning the containing div appropriately.

Parameters

NameTypeDescription
propsPopupPropsThe props.

Returns

Element

A popup near the point.

Defined in

components/Popup.tsx:35


SVGPin

SVGPin(props): Element

Render an SVG pin.

Parameters

NameTypeDescription
propsSVGPinPropsThe props.

Returns

Element

A map.

Defined in

components/SVGPin.tsx:37


ZoomButton

ZoomButton(props): Element

Render a zoom button.

Parameters

NameTypeDescription
propsZoomButtonPopsThe props.

Returns

Element

A map.

Defined in

components/ZoomButton.tsx:43


Other Functions

calcScaleInfo

calcScaleInfo(zoom, screenSize): ScaleInfo

Calculate scale factors.

The tiles are provide at discrete zoom levels starting at 0 where a single tile represents the world.

To provide smooth scrolling the width and height of the image tiles can be scaled.

Parameters

NameTypeDescription
zoomnumberThe zoom level
screenSizeSizeThe screen size

Returns

ScaleInfo

An object containing the rounded zoom, the scale, the scale width and height.

Defined in

tileMath.ts:88


calcWorldBounds

calcWorldBounds(center, zoom, bounds, tileSize): CoordinateBounds

Return the bounds of the view area in the world coordinate system.

Parameters

NameTypeDescription
centerCoordinateThe center of the map in world coordinates.
zoomnumberThe zoom level.
boundsBoundsThe bounds of the view area in the screen coordinate system.
tileSizeSizeThe size of a tile

Returns

CoordinateBounds

The bounds of the view area in the world coordinate system.

Defined in

tileMath.ts:272


coordinateToTilePoint

coordinateToTilePoint(coordinate, zoom): Point

Convert a latitude and longitude to an x and y point in the tile coordinate system.

Parameters

NameTypeDescription
coordinateCoordinateThe coordinate from which to calculate a tile point
zoomnumberThe zoom level

Returns

Point

The point in the tile coordinate system

Defined in

tileMath.ts:60


isCoordinateInWorldBounds

isCoordinateInWorldBounds(coordinate, worldBounds): boolean

Determine if a coordinate is inside the viewable area given in the world coordinate system.

Parameters

NameTypeDescription
coordinateCoordinateThe coordinate in the world coordinate system.
worldBoundsCoordinateBoundsThe bounds of the viewable area in the world coordinate system.

Returns

boolean

True if the coordinate was within the bounds; otherwise false.

Defined in

tileMath.ts:321


isInWorldBounds

isInWorldBounds(latitude, longitude, bounds): boolean

Determine if a coordinate is inside the viewable area given in the world coordinate system.

Parameters

NameTypeDescription
latitudenumberThe latitude.
longitudenumberThe longitude.
boundsCoordinateBoundsThe bounds of the viewable area in the world coordinate system.

Returns

boolean

True if the coordinate was within the bounds; otherwise false.

Defined in

tileMath.ts:300


limitCoordinate

limitCoordinate(coordinate, min?, max?): Coordinate

Limit a coordinate in the world coordinate system to be within the bounds of a minimum and maximum coordinate.

Parameters

NameTypeDefault valueDescription
coordinateCoordinateundefinedThe coordinate to limit.
minCoordinateLOCATIONS.southWestThe minimum allowed value.
maxCoordinateLOCATIONS.northEastThe maximum allowed value in the world coordinate system.

Returns

Coordinate

The value, limited by the minimum and maximum values.

Defined in

tileMath.ts:337


recenterScreenPoint

recenterScreenPoint(coordinate, center, zoom, screenSize, tileSize): Point

Convert a longitude and latitude to an x and y in the screen coordinate system.

Parameters

NameTypeDescription
coordinateCoordinateThe longitude and latitude of the point
centerCoordinateThe longitude and latitude of the center of the screen
zoomnumberThe zoom level
screenSizeSizeThe size of the screen
tileSizeSizeThe size of the tiles

Returns

Point

The x and y coordinates of the point in th screen coordinate system

Defined in

tileMath.ts:198


screenPointToCoordinate

screenPointToCoordinate(screenPoint, center, zoom, screenSize, tileSize, wrapLongitude?): Coordinate

Convert a screen point to a longitude and latitude.

Parameters

NameTypeDefault valueDescription
screenPointPointundefinedThe point in the screen coordinate system
centerCoordinateundefinedThe latitude and longitude of the center of the screen
zoomnumberundefinedThe zoom level
screenSizeSizeundefinedThe size of the screen
tileSizeSizeundefinedThe size of the tiles
wrapLongitudebooleantrue-

Returns

Coordinate

The longitude and latitude of the screen point

Defined in

tileMath.ts:147


screenToTilePoint

screenToTilePoint(screenPoint, tileSize): Point

Convert a point in the screen coordinate system to a point in the tile coordinate system.

Parameters

NameTypeDescription
screenPointPointA point in the screen coordinate system.
tileSizeSizeThe tile size.

Returns

Point

The point in the tile coordinate system.

Defined in

tileMath.ts:115


tilePointToCoordinate

tilePointToCoordinate(tilePoint, zoom): Coordinate

Convert an x and y point to a longitude and latitude coordinate.

Parameters

NameTypeDescription
tilePointPointThe x and y point in the tile coordinate system.
zoomnumberThe zoom level

Returns

Coordinate

The coordinate as a latitude and longitude

Defined in

tileMath.ts:72


useClick

useClick(__namedParameters): void

The useClick hook.

Parameters

NameType
__namedParametersuseClickProps

Returns

void

Defined in

hooks/useClick.ts:36


useDrag

useDrag(__namedParameters): [Coordinate, (center: Coordinate) => void]

A hook for mouse events.

Parameters

NameType
__namedParametersuseDragProps

Returns

[Coordinate, (center: Coordinate) => void]

Defined in

hooks/useDrag.ts:31


useZoom

useZoom(__namedParameters): [number, (zoom: number) => void]

A hook to integrate the zoom wheel with a map.

Parameters

NameType
__namedParametersuseZoomProps

Returns

[number, (zoom: number) => void]

Defined in

hooks/useZoom.ts:26


Tile Provider Functions

stamenTileProviderFactory

stamenTileProviderFactory(map): TileProvider

A tile provider factory for Stamen.

Parameters

NameTypeDescription
map"toner" | "terrain"The map to use

Returns

TileProvider

A tile provider for the requested Stamen map

Defined in

components/TileProviders.tsx:43