Class AutkMap

Source
Expand description

The main autark map class.

AutkMap encapsulates the core logic for initializing and rendering a map on a given HTML canvas element. It manages the camera, map rendering, map layers, and user interactions through keyboard, mouse, and map events.

example
const canvas = document.getElementById('map-canvas') as HTMLCanvasElement;
const boundingBox = /* { bounding box for the map } */ ;

const map = new AutkMap(canvas);
await map.init(boundingBox);

const geojsonData = { /* GeoJSON data */ };
map.loadGeoJsonLayer('my_data', LayerType.CUSTOM_FEATURES_LAYER, geojsonData);

Constructors§

Source§

new AutkMap(canvas: HTMLCanvasElement, autoResize?: boolean): AutkMap

Creates an instance of the AutkMap class.

Properties§

Source§

protected _camera: Camera

The camera instance used for rendering the map

Source§

protected _canvas: HTMLCanvasElement

The canvas element used for rendering the map

Source§

protected _keyEvents: KeyEvents

The key events handler for keyboard interactions

Source§

protected _layerManager: LayerManager

The layer manager instance used for managing map layers

Source§

protected _mapEvents: MapEvents

The map events handler for map interactions

Source§

protected _mouseEvents: MouseEvents

The mouse events handler for mouse interactions

Source§

protected _renderer: Renderer

The renderer instance used for rendering the map

Source§

protected _ui: AutkMapUi

The UI instance for managing the map's user interface

Accessors§

Source§

get boundingBox(): BBox

Gets the bounding box of the map.

Source§

set boundingBox(bbox: BBox): void

Source§

get camera(): Camera

Gets the camera instance used for rendering the map.

Source§

set camera(camera: Camera): void

Sets the camera instance used for rendering the map.

Source§

get canvas(): HTMLCanvasElement

Gets the canvas element used for rendering the map.

Source§

get layerManager(): LayerManager

Gets the layer manager instance used for managing map layers.

Source§

get mapEvents(): MapEvents

Gets the map events instance used for handling map interactions.

Source§

get origin(): number[]

Gets the origin of the map, which is the center of the bounding box.

Source§

get renderer(): Renderer

Gets the renderer instance used for rendering the map.

Source§

get ui(): AutkMapUi

Gets the UI instance used for managing the map's user interface.

Methods§

Source§

draw(fps?: number): void

Starts the drawing loop.

Source§

init(): Promise<void>

Initializes the map.

Source§

loadGeoJsonLayer(
    layerName: string,
    geojson: FeatureCollection,
    typeLayer?: LayerType | null,
): void

Loads a GeoJSON layer into the map.

This method creates a layer based on the provided GeoJSON data and adds it to the map's layer manager. Supported OSM layer types include:

  • AUTK_OSM_SURFACE
  • AUTK_OSM_WATER
  • AUTK_OSM_PARKS
  • AUTK_OSM_ROADS
  • AUTK_OSM_BUILDINGS

Custom layers can also be loaded with types:

  • AUTK_GEO_POINTS
  • AUTK_GEO_POLYLINES
  • AUTK_GEO_POLYGONS
  • AUTK_RASTER
Source§

loadGeoTiffLayer(
    layerName: string,
    geotiff: FeatureCollection,
    typeLayer?: LayerType | null,
): void

Loads a GeoTIFF layer into the map. This method creates a layer based on the provided GeoTIFF data and adds it to the map's layer manager.

Source§

updateGeoJsonLayerThematic(
    layerName: string,
    geojson: FeatureCollection,
    getFnv: (feature: Feature) => string | number,
    groupById?: boolean,
): void

Updates the thematic information of a layer based on a GeoJSON source.

This method extracts thematic values from the GeoJSON features using the provided function, normalizes these values, and updates the layer's thematic data accordingly.

Source§

updateLayerGeometry(layerName: string, layerGeometry: ILayerGeometry[]): void

Updates the geometry of a layer.

Source§

updateLayerThematic(layerName: string, layerThematic: ILayerThematic[]): void

Updates the thematic information of a layer.

Source§

updateRenderInfoProperty(
    layerName: string,
    property: keyof ILayerRenderInfo,
    value: unknown,
): void

Updates the render information of a layer.