XYZ Maps Documentation
    Preparing search index...

    Class RemoteTileProvider

    A remote tile provider fetches data from remote data-sources.

    Hierarchy (View Summary)

    Index
    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

    • Add a feature to the provider.

      Parameters

      Returns Feature

      // add a feature to the provider.
      provider.addFeature({
      type: "Feature"
      geometry: {
      coordinates: [[-122.49373, 37.78202], [-122.49263, 37.78602]],
      type: "LineString"
      }
      });
    • Add multiple features to the provider.

      Parameters

      Returns Feature<string>[]

      // add multiple features to the provider.
      provider.addFeature([{
      type: "Feature"
      geometry: {
      coordinates: [[-122.49373, 37.78202], [-122.49263, 37.78602]],
      type: "LineString"
      }
      },{
      type: "Feature"
      geometry: {
      coordinates: [[-122.49375, 37.78203], [-122.49265, 37.78604]],
      type: "LineString"
      }
      }]);
    • Add a feature to the provider.

      Parameters

      Returns any

      // add a feature to the provider.
      provider.addFeature({
      type: "Feature"
      geometry: {
      coordinates: [[-122.49373, 37.78202], [-122.49263, 37.78602]],
      type: "LineString"
      }
      });
    • Cancel ongoing request(s) of a tile. The tile will be dropped.

      Parameters

      • quadkey: string

        the quadkey of the tile that should be canceled and removed.

      Returns void

    • Cancel ongoing request(s) of a tile. The tile will be dropped.

      Parameters

      • tile: Tile

        the tile that should be canceled and removed.

      Returns void

    • Cancel ongoing request(s) of a tile. The tile will be dropped.

      Parameters

      • tile: string | Tile
      • Optionalcb: any

      Returns void

    • 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

      • cfg: any

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

      Returns TileProviderOptions

    • Create a new Tile.

      Parameters

      • quadkey: string

        the quadkey of the tile to create

      Returns Tile

    • 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);
    • Get a locally cached tile by quadkey.

      Parameters

      • quadkey: string

        the quadkey of the tile

      Returns Tile

    • 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. Data will be fetched from remote data-sources and attached to tile automatically

      Parameters

      • quadkey: string

        quadkey of the tile

      • callback: (tile: Tile) => void

        will be called as soon as tile is ready for consumption

      Returns any

      the Tile

    • 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