On this page

Class Map

The main Map class for creating and controlling a MapTiler WebGPU interactive map.

import { Map } from '@maptiler/geosplats';

const map = new Map({
  container: 'map',
  apiKey: 'YOUR_MAPTILER_API_KEY_HERE',
  center: [16.37, 48.21],
  zoom: 12
});

Hierarchy (View Summary)

Index

Constructors

  • Creates a new Map instance.

    Parameters

    Returns Map

    const map = new Map({
      apiKey: 'YOUR_MAPTILER_API_KEY_HERE',
      container: 'map',
      center: [14.454266, 50.089376],
      zoom: 12,
      debug: true
    });
    

Properties

loaded: boolean = false

Methods

  • Adds a SplatModel visualization to the map.

    Parameters

    • splatModel: SplatModel

      The SplatModel instance to add.

    • cameraParams: CameraParams | null = null

      optional pitch and bearing for camera.

    Returns void

    const splatModel = new SplatModel({ model: "model_url" });
    map.on('load', () => {
      map.addSplatModel(splatModel);
    });
    
  • Moves the camera such that the provided bounds are visible.

    Parameters

    Returns void

    map.fitBounds([
      [14.408177, 50.080911],
      [14.440250, 50.085178]
    ]);
    
  • Returns the current terrain exaggeration factor.

    Parameters

    • position: LngLatLike

      LngLat position.

    • callback: (altitude: number) => void

      Function called with the position's altitude or NaN if position is invalid or basemap is VOID.

    Returns void

  • Returns the current bearing (rotation) of the map in degrees.

    Returns number

    The bearing in degrees.

  • Returns the current center of the map.

    Parameters

    • callback: (center: LngLat) => void

      Function called with the center position.

    Returns void

  • Returns the current field of view (FOV) of the map.

    Returns number

    The FOV in degrees.

  • Returns the maximum allowed pitch (tilt).

    Returns number

    The maximum pitch.

  • Returns the minimum allowed pitch (tilt).

    Returns number

    The minimum pitch.

  • Returns the current pitch (tilt) of the map in degrees.

    Returns number

    The pitch in degrees.

  • Returns the current zoom level of the map.

    Returns number

    The zoom level.

  • Instantly moves the camera to the specified position and zoom.

    Parameters

    Returns void

    map.jumpTo({
      center: [13.497569, 47.344369],
      zoom: 12,
      pitch: 80,
      bearing: 60,
    });
    
  • Removes the map and cleans up all related resources.

    Returns void

  • Removes a SplatModel visualization from the map.

    Parameters

    • splatModel: SplatModel

      The SplatModel instance to remove.

    Returns void

  • Sets the bearing (rotation) of the map.

    Parameters

    • bearing: number

      The new bearing in degrees.

    Returns void

  • Sets the center position of the map.

    Parameters

    Returns void

  • Sets the maximum pitch (tilt) of the map.

    Parameters

    • pitch: number

      The new maximum pitch, from 0 to 180.

    Returns void

  • Sets the minimum pitch (tilt) of the map.

    Parameters

    • pitch: number

      The new minimum pitch, from 0 to 180.

    Returns void

  • Changes rendered model quality.

    Parameters

    • resolution: ModelResolutionType

      sets render quality for models. QUALITY option might have impact on performance.

    Returns void

  • Sets the pitch (tilt) of the map.

    Parameters

    • pitch: number

      The new pitch in degrees.

    Returns void

  • Locks or unlocks the current pitch of the map.

    Parameters

    • locked: boolean

      Whether to lock the pitch.

    Returns void

  • Sets the zoom level of the map.

    Parameters

    • zoom: number

      The new zoom level.

    Returns void

  • Zooms in by one level.

    Returns void

  • Zooms out by one level.

    Returns void

Was this helpful?

GeoSplats SDK
Reference
Map