XYZ Maps Documentation
    Preparing search index...

    XYZ Map is a highly customizable WebGL based vector map display that's optimized for map editing, larger raw datasets and frequently changing data.

    Index
    • Parameters

      • mapElement: HTMLElement

        HTMLElement used to create the map display

      • options: MapOptions

        options to configure for the map

      Returns Map

      import {Map} from '@here/xyz-maps-display';

      //create map display
      const display = new Map( mapDiv, {
      zoomLevel : 19,
      center: {
      longitude: 8.53422,
      latitude: 50.16212
      },
      // add layers to display
      layers: layers
      });
    • Adds an event listener to the map. supported events: 'mapviewchangestart', 'mapviewchange', 'mapviewchangeend', 'resize', 'tap', 'dbltap', 'pointerup', 'pointerenter', 'pointerleave', 'pointerdown', 'pointermove', 'pressmove'

      Parameters

      • type: string

        A string representing the event type to listen for.

      • listener: (e: MapEvent) => void

        the listener function that will be called when an event of the specific type occurs

      Returns void

    • Adds a layer to the map.

      If an index is provided, the layer will be inserted at the specified position within the layer hierarchy, which allows placing the layer between existing layers. If the index is not specified, the layer will be added on top of all existing layers (i.e., as the last layer in the hierarchy).

      The index is zero-based, meaning an index of 0 will insert the layer at the bottom, and an index equal to the current number of layers will place it on top. If the specified index exceeds the current number of layers, the layer will be added on top.

      Parameters

      • layer: TileLayer | CustomLayer

        The layer to be added to the map. This can be a TileLayer or a CustomLayer.

      • Optionalindex: number

        (Optional) The zero-based index in the layer hierarchy where the layer should be inserted. If omitted, the layer will be added as the topmost layer.

      Returns void

    • Add an observer to the map. Supported observers are: "zoomlevel", "center", "rotation" and "pitch".

      Parameters

      • name: string

        the name of the value to observe

      • observer: (name: string, newValue: any, prevValue: any) => void

        the observer that will be executed on value changes.

      Returns boolean

      boolean that's indicating if observer was added.

    • Destroy the the map.

      Returns void

    • Set the map center using a bow animation combining pan and zoom operations.

      Parameters

      • center: GeoPoint

        the geographical coordinate to center the map.

      • Optionaloptions: { duration?: number }

        options to configure the bow animation

        • Optionalduration?: number

          the duration of the bow animation in milliseconds

      Returns any

    • Set the map center and zoomlevel using a bow animation combining pan and zoom operations.

      Parameters

      • center: GeoPoint

        the geographical coordinate to center the map.

      • zoomTo: number

        the zoomlevel the map should be zoomed to.

      • Optionaloptions: { duration?: number }

        options to configure the bow animation

        • Optionalduration?: number

          the duration of the bow animation in milliseconds

      Returns any

    • Convert a geographical coordinate to a pixel coordinate relative to the current viewport of the map.

      Parameters

      • longitude: number

        the longitude in degrees

      • latitude: number

        the latitude in degrees

      • Optionalaltitude: number

        the altitude in meters

      Returns PixelPoint

      the pixel coordinate relative to the current viewport.

    • Convert a geographical coordinate to a pixel coordinate relative to the current viewport of the map.

      Parameters

      • coordinate: GeoPoint

        the geographical coordinate

      Returns PixelPoint

      the pixel coordinate relative to the current viewport.

    • Get current active map behavior options.

      Returns {
          drag: boolean;
          pitch: boolean;
          pitchAndRotateModifiers: ModifierKey | ModifierKey[];
          rotate: boolean;
          zoom: boolean;
      }

      • drag: boolean

        indicates if map dragging is enabled or disabled.

      • pitch: boolean

        indicates if map pitching is enabled or disabled.

      • pitchAndRotateModifiers: ModifierKey | ModifierKey[]

        Modifier key or keys for the combined pitch and rotation gesture.

      • rotate: boolean

        indicates if map rotation is enabled or disabled.

      • zoom: boolean

        indicates if map zooming is enabled or disabled.

    • Experimental

      Get the camera of the current viewport.

      Returns { position: { altitude: number; latitude: number; longitude: number } }

      • position: { altitude: number; latitude: number; longitude: number }

        The camera's center position in geographical coordinates (world-space).

    • Get the current geographical center of the map.

      Returns GeoPoint

      the map's geographical center point.

    • Get the HTMLElement used by the map.

      Returns HTMLElement

    • Get most top rendered feature within the given area of map

      Parameters

      • position: PixelPoint | PixelRect

        Point or Rect in pixel to define search area. If a Point is used, width and height must be passed in options parameter.

      • Optionaloptions: { height?: number; layers?: TileLayer | TileLayer[]; width?: number }

        Describing the options param

        • Optionalheight?: number

          height in pixel of rectangle if point geometry is used.

        • Optionallayers?: TileLayer | TileLayer[]

          defines the layer(s) to search in.

        • Optionalwidth?: number

          width in pixel of rectangle if point geometry is used.

      Returns { feature: Feature; layer: TileLayer }

      The result providing found feature and layer. undefined is returned if nothing is found.

    • Get rendered features within the given area of map

      Parameters

      • position: PixelPoint | PixelRect

        Point or Rect in pixel to define search area. If a Point is used, width and height must be passed in options parameter.

      • Optionaloptions: { height?: number; layers?: TileLayer | TileLayer[]; width?: number }

        Describing the options param

        • Optionalheight?: number

          height in pixel of rectangle if point geometry is used.

        • Optionallayers?: TileLayer | TileLayer[]

          defines the layer(s) to search in.

        • Optionalwidth?: number

          width in pixel of rectangle if point geometry is used.

      Returns { features: Feature<string>[]; layer: TileLayer }[]

      zIndex ordered results array

    • Get the current height in pixels of map.

      Returns number

    • Get the current added layer(s) of the map.

      Returns TileLayer[]

      the layer(s) that are added to the map

    • Get a specific Layer of the map.

      Parameters

      • index: number

        get a specific layer at index in the layer hierarchy

      Returns TileLayer

      the layer that is added to the map

    • Returns the 3D geographic coordinates (including elevation) of the terrain at a given screen position.

      This method performs a raycast from the screen pixel into the scene and returns the intersection point on the terrain surface, if available.

      It can be used to convert screen positions into real-world terrain positions, including altitude based on the terrain elevation data.

      Parameters

      • screen: PixelPoint

        The screen (pixel) coordinates {x, y} to query.

      Returns GeoPoint

      A GeoPoint object {longitude, latitude, altitude} representing the 3D position on the terrain, or null if the terrain data is not yet loaded or if the ray does not intersect any terrain surface.

      const terrainPoint = map.getTerrainPointAt({x: 300, y: 200});
      if (terrainPoint) {
      console.log(`Longitude: ${terrainPoint.longitude}`);
      console.log(`Latitude: ${terrainPoint.latitude}`);
      console.log(`Altitude: ${terrainPoint.altitude} m`);
      }
    • Gets the current view bounds of the view port.

      Returns GeoRect

    • Get the current width in pixels of map.

      Returns number

    • Get the current zoom level

      Returns number

      the current zoom level of the map

    • get the current applied lock status of the map.

      Returns { maxLevel: number; minLevel: number; pan: boolean }

      the current applied lock options.

    • set lock the viewport of the map. by indicating if panning, minLevel and maxLevel should be locked.

      Parameters

      • options: { maxLevel?: number; minLevel?: number; pan?: boolean }

        the lock options.

        • OptionalmaxLevel?: number

          the maximum allowed zoom level that can be zoomed to.

        • OptionalminLevel?: number

          the minimum allowed zoom level that can be zoomed to.

        • Optionalpan?: boolean

          true to enable panning, false to disable panning.

      Returns { maxLevel: number; minLevel: number; pan: boolean }

      the current applied lock options.

    • Shift the geographical center of the map in pixels.

      Parameters

      • dx: number

        distance in pixels to pan the map on x axis

      • dy: number

        distance in pixels to pan the map on y axis

      Returns void

    • Set or get map pitch (tilt) in degrees

      Parameters

      • Optionalpitch: number

        pitch in degrees

      Returns number

    • Converts from screen pixel to geo coordinate

      Parameters

      • x: number

        the x position on screen in pixel

      • y: number

        the y position on screen in pixel

      Returns GeoPoint

      the geographical coordinate

    • Converts from screen pixel to geo coordinate

      Parameters

      • position: PixelPoint

        the pixel coordinate on screen

      Returns GeoPoint

      the geographical coordinate

    • Refresh the map view. Manually trigger re-rendering of specific layer(s) of the map.

      Parameters

      Returns void

    • Removes an event listener to the map.

      Parameters

      • type: string

        A string representing the event type to listen for.

      • listener: (e: MapEvent) => void

        The EventListener function of the event handler to remove from the editor.

      Returns void

    • Removes an observer from the map.

      Parameters

      • name: string

        the name of the value to observe

      • observer: (name: string, newValue: any, prevValue: any) => void

        the observer that should be removed.

      Returns boolean

      boolean that's indicating if observer was removed.

    • Resize the map view. If no width/height is passed the map will resize automatically to the maximum possible size defined by the HTMLElement.

      Parameters

      • Optionalwidth: number

        new width in pixels

      • Optionalheight: number

        new height in pixels

      Returns void

    • Set or get map rotation along z-axis

      Parameters

      • Optionalrotation: number

        set absolute map rotation in degrees

      Returns number

      current applied rotation in degrees

    • Adjusts the map zoom level so that the camera altitude matches the target altitude. Moves the camera straight up or down — elevator style — while keeping the ground point directly beneath the camera fixed in the same screen position.

      Unlike a plain setZoomlevel(), which zooms towards a specified anchor point (default: map center), this method ensures the zoom is anchored to the point directly under the camera.

      Pitch and bearing remain unchanged, so the map center (lookAt) will shift as altitude changes.

      Parameters

      • targetAltitude: number

        The desired camera altitude in meters.

      • Optionalduration: number = 0

        Optional zoom animation duration in milliseconds.

      Returns void

    • Sets the background color of the map.

      The background color of the layer at index 0 takes precedence over this color. If that layer has no background color, or the map has no layers, the updated map background color is used.

      Parameters

      • color: Color

        the background color to set

      Returns void

    • Set the map behavior on user interaction.

      Parameters

      • options: {
            drag?: boolean;
            pitch?: boolean;
            pitchAndRotateModifiers?: ModifierKey | ModifierKey[];
            rotate?: boolean;
            zoom?: boolean;
        }

        Behavior options

        • Optionaldrag?: boolean

          true to enable map dragging, false to disable.

        • Optionalpitch?: boolean

          true to enable map pitching, false to disable.

        • OptionalpitchAndRotateModifiers?: ModifierKey | ModifierKey[]

          Modifier key or keys for the combined pitch and rotation gesture.

        • Optionalrotate?: boolean

          true to enable map rotation, false to disable.

        • Optionalzoom?: boolean

          true to enable map zooming, false to disable.

      Returns void

      // to deactivate map zoom on mouse scroll:
      setBehavior({zoom: false, drag: true});
    • Enable/Disable a specific map behavior on user interaction. Possible behavior are: "zoom", "drag", "pitch" and "rotate

      Parameters

      • behavior: string

        the behavior that should be disabled or enabled.

      • active: boolean

        true to enable, false to disable

      Returns any

      // to deactivate map zoom on mouse scroll:
      setBehavior('zoom',true);
    • Set new geographical center for the map.

      Parameters

      • center: GeoPoint

        the geographical coordinate to center the map

      Returns any

      display.setCenter({longitude: 8.53422, latitude: 50.16212});
      
    • Set new geographical center for the map.

      Parameters

      • longitude: number | GeoPoint

        longitude to center the map

      • latitude: number

        latitude to center the map

      Returns any

      display.setCenter(8.53422, 50.16212);
      
    • Set view bounds for the map to display.

      Parameters

      • bounds:
            | GeoRect
            | [number, number, number, number]
            | GeoJSONFeature<string>
            | GeoJSONFeature<string>[]
            | GeoJSONFeatureCollection

        GeoRect, GeoJson Feature or an GeoJson bbox [minLon, minLat, maxLon, maxLat] defining the view bounds.

      • Optionalanimate: boolean

        animate using a bow animation

      Returns any

      Map.flyTo. true to enable, false to disable.

    • Set view bounds for the map to display.

      Parameters

      • bounds:
            | GeoRect
            | [number, number, number, number]
            | GeoJSONFeature<string>
            | GeoJSONFeature<string>[]
            | GeoJSONFeatureCollection

        GeoRect, GeoJson Feature or an GeoJson bbox [minLon, minLat, maxLon, maxLat] defining the view bounds.

      • OptionalanimationOptions: { duration?: number }

        options to configure the bow animation

        • Optionalduration?: number

          the duration of the bow animation in milliseconds

      Returns any

      Map.flyTo.

    • Set zoomlevel with an optional anchor point.

      Parameters

      • zoomTo: number

        new zoomlevel

      • OptionalfixedX: number

        x coordinate of fixed anchor point on screen in pixels

      • OptionalfixedY: number

        y coordinate of fixed anchor point on screen in pixels

      • Optionalanimate: number

        zoom transition animation time in milliseconds [default: 0]

      Returns void

    • Take a snapshot of the current map's viewport.

      Parameters

      • callback: (screenshot: HTMLCanvasElement) => void

        Callback function that will be called when the requested snapshot has been captured.

          • (screenshot: HTMLCanvasElement): void
          • Parameters

            • screenshot: HTMLCanvasElement

              A HTMLCanvasElement containing the requested screenshot.

            Returns void

      • Optionaldx: number

        x coordinate of the left edge of the capturing rectangle in pixel

      • Optionaldy: number

        y coordinate of the top edge of the capturing rectangle in pixel

      • Optionalwidth: number

        width of the capturing rectangle in pixel

      • Optionalheight: number

        height of the capturing rectangle in pixel

      Returns void