XYZ Maps Documentation
    Preparing search index...

    Class LocalProvider

    Local feature tile provider.

    Hierarchy (View Summary)

    Index
    hooks?: {
        "Coordinates.update"?: CoordinatesUpdateHook | CoordinatesUpdateHook[];
        "Feature.remove"?: FeatureRemoveHook | FeatureRemoveHook[];
        "Navlink.disconnect"?: NavlinkDisconnectHook | NavlinkDisconnectHook[];
        "Navlink.split"?: NavlinkSplitHook | NavlinkSplitHook[];
    }

    Hook functions that will be called during the execution of the corresponding "editing operation". The "hooks" property is a map with the "editing operation" as its key and the corresponding Hook or Array of Hook function(s) as its value.

    Available editing operations are 'Navlink.disconnect', 'Navlink.split', 'Feature.remove', 'Coordinates.remove'.

    id?: string

    The id of the Provider

    margin?: number = 0

    default tile margin.

    name?: string

    The name of the Provider.

    • Add an EventListener to the provider. Valid events: "featureAdd", "featureRemove", "featureCoordinatesChange", "clear" and "error"

      The detail property of the Event gives additional information about the event. detail.provider is a reference to the provider onto which the event was dispatched and is set for all events.

      Parameters

      • type: string

        A string representing the event type to listen for

      • listener: (e: CustomEvent) => void

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

      • Optional_c: any

      Returns boolean

    • Get or set configuration options for the provider.

      If a string is provided as the first argument, returns the value of the corresponding property. If an object is provided, sets the provider's properties according to the object.

      Parameters

      • options: string | TileProviderOptions

        The configuration key as a string to get a value, or an object to set multiple options.

      • Optionalvalue: any

        Optional value to set if a string key is provided.

      Returns TileProviderOptions

    • Validate if a feature is stored in the local provider cache.

      Parameters

      • feature: { id: string | number }

        Object literal containing "id" property.

      Returns { feature?: Feature }

      the Feature if it is found, otherwise undefined

    • Experimental

      Finds the optimal path between two coordinates on a GeoJSON road network, considering various options. By default, the weight function returns the distance of the road segment, a lower distance implies a shorter route and is considered more favorable. If you have specific criteria such as road quality, traffic conditions, or other factors influencing the desirability of a road segment, you can customize the weight function accordingly. Pathfinding will consider only the locally cached data available on the client.

      Parameters

      • options: {
            allowTurn?: (
                turn: {
                    from: { index: number; link: Feature<"LineString"> };
                    to: { index: number; link: Feature<"LineString"> };
                },
            ) => boolean;
            from: GeoPoint
            | GeoJSONCoordinate;
            to: GeoPoint | GeoJSONCoordinate;
            weight?: (
                data: {
                    direction: "START_TO_END" | "END_TO_START";
                    distance: number;
                    feature: Feature<"LineString">;
                    from: GeoJSONCoordinate;
                    to: GeoJSONCoordinate;
                },
            ) => number;
        }

        The options object containing parameters for finding the path.

        • OptionalallowTurn?: (
              turn: {
                  from: { index: number; link: Feature<"LineString"> };
                  to: { index: number; link: Feature<"LineString"> };
              },
          ) => boolean

          Optional callback function to determine if a turn is allowed between road segments. If not provided, all turns are considered allowed.

        • from: GeoPoint | GeoJSONCoordinate

          The starting coordinates defining the path.

        • to: GeoPoint | GeoJSONCoordinate

          The ending coordinates of the path.

        • Optionalweight?: (
              data: {
                  direction: "START_TO_END" | "END_TO_START";
                  distance: number;
                  feature: Feature<"LineString">;
                  from: GeoJSONCoordinate;
                  to: GeoJSONCoordinate;
              },
          ) => number

          Optional callback function to determine the weight (cost) of traversing a road segment.

      Returns Promise<
          {
              distance: number;
              features: Feature<"LineString">[];
              from: GeoJSONCoordinate;
              path: GeoJSONFeature<"MultiLineString">;
              to: GeoJSONCoordinate;
          },
      >

      A Promise that resolves to an object containing the path, additional information, and the distance of the path.

      const pathOptions = {
      from: [startLongitude, startLatitude],
      to: [endLongitude, endLatitude],
      // optional
      allowTurn: (turn) => {
      // Custom logic to determine whether a turn is allowed
      return true;
      },
      // optional
      weight: (data) => {
      // Custom weight function to determine the cost of traversing a road segment
      return data.distance; // Default implementation uses distance as the weight
      },
      };
      const result = await provider.findPath(pathOptions);
      console.log(result);
    • Retrieves cached tiles within a specified bounding box or all cached tiles if no parameters are provided.

      If no arguments are passed, all cached tiles are returned. If a bounding box (bbox) and/or zoom level (zoomlevel) are provided, it filters the cached tiles based on the specified area and zoom level.

      Parameters

      • Optionalbbox: number[]

        An optional array of coordinates defining the bounding box in the format: [minLon, minLat, maxLon, maxLat]. If provided, only tiles within this geographic area will be returned.

      • Optionalzoomlevel: number

        An optional zoom level to filter tiles. If provided, only tiles at the specified zoom level will be returned.

      Returns Tile[]

      • An array of Tile objects that match the specified parameters, or all cached tiles if no parameters are given.
    • Gets a feature from the provider by id.

      Parameters

      • id: string | number

        the id of the feature

      Returns Feature<string>

      the found feature or undefined if feature is not present.

    • Gets features from provider by id.

      Parameters

      • ids: number[] | string[]

        array of feature ids to search for.

      Returns Feature<string> | Feature<string>[]

      if just a single feature is found its getting returned otherwise an array of features or undefined if none is found.

    • Get a tile by quadkey. If the tile is not cached already, it will be created and stored automatically.

      Parameters

      • quadkey: string

        quadkey of the tile

      • Optionalcallback: (tile: Tile) => void

        the callback function

      Returns Tile

      the Tile

    • Read intersection-related connectivity for a Navlink node.

      This method allows an EditableFeatureProvider to override the default geometric intersection detection.

      It is called for the start or end node of a Navlink to determine whether that node forms an intersection and which Navlinks are connected to it.

      Implement this if intersection information is stored in feature properties, derived from external metadata, or otherwise known in advance.

      Return values:

      • undefined → No custom information is provided. The editor falls back to geometric intersection detection.

      • [] (empty array) → Explicitly no connected links at this node. The editor will NOT perform geometric detection.

      • [ { id, index? }, ... ] → Explicitly defined connected Navlinks, referenced by their feature ID. If index is omitted, the editor automatically determines the corresponding node coordinate of the connected link.

      Parameters

      • link: Feature

        The Navlink feature whose node connectivity is being read.

      • index: number

        The coordinate index of the node (0 → start node, last coordinate → end node).

        Note: Regardless of the returned value, geometric requirements for intersection (such as spatial proximity and coordinate precision) must still be fulfilled. See the intersectionScale property for details.

      Returns { index?: number; link: string | number }[] | []

      An array of { id: string | number; index?: number }, an empty array to signal "no connection", or undefined to fall back to default detection.

    • Attribute reader for obtaining the direction of travel of a Navlink feature.

      This method must be implemented to enable editing of Navlinks.

      Parameters

      • link: Feature

        the Navlink whose direction is requested

      Returns "BOTH" | "START_TO_END" | "END_TO_START"

    • Attribute reader for obtaining the Height of a Building (extruded Area). The height must be specified in meters.

      This method must be implemented to enable editing of the height of an extruded Area.

      Parameters

      • feature: Feature

        The Area feature whose height is requested.

      Returns number

      The height in meters of the Building/Area or null if the Area is considered flat.

    • Attribute reader for obtaining if a Navlink feature can be accessed by pedestrians only.

      This method must be implemented to enable editing of Navlinks.

      Parameters

      Returns boolean

      true, if the Navlink can be accessed by pedestrians only, otherwise false.

    • Attribute reader for obtaining the id of the Navlink Feature on which the RoutingPoint of an Address or Place feature is located. For Addresses an Id must be returned. If null is returned for a Place, the Place is treated as "floating" without a RoutingPoint.

      This method must be implemented to enable editing of Places or Addresses.

      Parameters

      • feature: any

        The Address or Place of which the Navlink of the RoutingPoint is requested.

      Returns string | number

      the Id of the Navlink on which the RoutingPoint is located.

    • Attribute reader for obtaining the RoutingPoint's geographical position of an Address or Place. The geographical position must be located on the geometry of the related Navlink feature.

      This method must be implemented to enable editing of Places or Addresses.

      Parameters

      • feature: any

        The Address or Place feature whose RoutingProvider is requested.

      Returns GeoJSONCoordinate

      GeoJSON Coordinate representing the geographical position of the RoutingPoint or null if a Place does not have a RoutingPoint.

    • Attribute reader for obtaining the id of the TileProvider containing the corresponding Navlink, of an Address or Place feature, on which the RoutingPoint is located.

      This method must be implemented to enable editing of Places or Addresses.

      Parameters

      Returns string

      the Id of the TileProvider in which the object is stored. If undefined is returned, the RoutingPoint's Navlink is assumed to be in the same TileProvider as the Address/Place.

    • Attribute reader for obtaining the turn-restrictions of two Navlink Features.

      This method must be implemented to enable editing of Navlinks.

      Parameters

      • turnFrom: { index: number; link: Feature }

        The Navlink and it's coordinate index from which to turn from

      • turnTo: { index: number; link: Feature }

        The Navlink and it's coordinate index to which you want to turn

      Returns boolean

      true if turn is allowed, otherwise false.

    • Attribute reader for obtaining the zLevels of a Navlink feature.

      This method must be implemented to enable editing of Navlinks.

      Parameters

      • link: Feature

        the Navlink whose zLevels are requested

      Returns number[]

      An array containing the zLevel for each coordinate of the Navlink.

    • Remove an EventListener from the provider. Valid events: "featureAdd", "featureRemove", "featureCoordinatesChange", "clear" and "error"

      Parameters

      • type: string

        A string which specifies the type of event for which to remove an event listener.

      • listener: (event: CustomEvent) => void

        The listener function of the event handler to remove from the provider.

      • Optional_c: any

      Returns boolean

    • Search for feature(s) in the provider.

      Parameters

      • options: {
            id?: string | number;
            ids?: number[] | string[];
            point?: GeoPoint;
            radius?: number;
            rect?: GeoRect | GeoJSONBBox;
        }

        configure the search

        • Optionalid?: string | number

          search feature by id.

        • Optionalids?: number[] | string[]

          Array of feature ids to search.

        • Optionalpoint?: GeoPoint

          Geographical center point of the point to search in. options.radius must be defined.

        • Optionalradius?: number

          Radius of the point in meters, it is used in "point" search.

        • Optionalrect?: GeoRect | GeoJSONBBox

          Geographical Rectangle to search in. [minLon, minLat, maxLon, maxLat] | GeoRect.

      Returns Feature<string> | Feature<string>[]

      array of features

      // searching by id:
      layer.search({id: 1058507462})
      // or:
      layer.search({ids: [1058507462, 1058507464]})

      // searching by point and radius:
      layer.search({
      point: { longitude: 72.84205, latitude: 18.97172 },
      radius: 100
      })

      // searching by Rect:
      layer.search({
      rect: { minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876 }
      })
    • Point Search for feature(s) in provider.

      Parameters

      • point: GeoPoint

        Geographical center point of the point to search in. options.radius must be defined.

      • Optionaloptions: { radius: number }

        configure the search

        • radius: number

          The radius of the circular area in meters to search in.

      Returns Feature<string>[]

      layer.search({longitude: 72.84205, latitude: 18.97172},{
      radius: 100
      })
      // or:
      layer.search([72.84205, 18.97172], {
      radius: 100
      })
    • Rectangle Search for feature(s) in provider.

      Parameters

      • rect: GeoRect | GeoJSONBBox

        Geographical Rectangle to search in. [minLon, minLat, maxLon, maxLat] | GeoRect.

      Returns Feature<string>[]

      layer.search({minLon: 72.83584, maxLat: 18.97299, maxLon: 72.84443, minLat: 18.96876})
      // or:
      layer.search([72.83584, 18.96876, 72.84443,18.97299])
    • Search for feature by id in the provider.

      Parameters

      • id: string | number

        id of the feature to search for

      Returns Feature

      layer.search(1058507462)
      
    • Set the tile margin in pixel.

      Parameters

      • tileMargin: number = 0

        the tileMargin

      Returns void

    • Attribute writer for storing the EditStates of a Feature. The EditStates provide information about whether a feature has been created, modified, removed or split.

      By default EditStates aren't tracked/stored.

      Parameters

      • feature: Feature

        The Feature whose EditState should be written.

      • editState: "created" | "modified" | "removed" | "split"

        the EditState to store

      Returns void

    • Attribute writer for storing the Height of a Building (extruded Area). The height must be specified in meters.

      This method must be implemented to enable editing of the height of an extruded Area.

      Parameters

      • feature: Feature

        The Area feature whose height should be updated/written.

      • height: number

        The height specified in meters

      Returns void

    • Attribute writer for storing the Navlink reference on which the RoutingPoint of an Address or Place feature is located.

      This method must be implemented to enable editing of Places or Addresses.

      Parameters

      • location: any

        The Address or Place of which the Navlink reference of the RoutingPoint to store.

      • link: Feature

      Returns void

    • Attribute writer to store the RoutingPoint's geographical position of an Address or Place. The geographical position must be located on the geometry of the related Navlink feature.

      This method must be implemented to enable editing of Places or Addresses.

      Parameters

      • feature: any

        The Address or Place feature whose RoutingPoint position to write.

      • position: GeoJSONCoordinate

        the geographical position of the RoutingPoint.

      Returns void

    • Attribute writer for writing a turn restriction between two Navlink features.

      This method must be implemented to enable editing of Navlinks. It defines whether a turn from one Navlink to another is permitted or restricted.

      Parameters

      • restricted: boolean

        Specifies whether the turn is forbidden (true) or allowed (false).

      • turnFrom: { index: number; link: Feature }

        The originating Navlink and its coordinate index from which the turn starts.

      • turnTo: { index: number; link: Feature }

        The destination Navlink and its coordinate index to which the turn is directed.

      Returns void

    • Attribute writer for writing the zLevels of a Navlink feature.

      This method must be implemented to enable editing of Navlinks.

      Parameters

      • link: Feature

        the Navlink whose zLevels should be set

      • zLevels: number[]

        An array containing the zLevel for each coordinate of the Navlink

      Returns void

      An array containing the zLevel for each coordinate of the Navlink.