rapid-sdk
    Preparing search index...
    Index

    Constructors

    • Constructs a new Tiler

      Returns Tiler

      By default, the tiler uses a 256px tilesize, a zoomRange of 0-24, fetches no margin tiles beyond the viewport, and includes data around "Null Island". (These defaults can be changed at any time by using accessor methods.)

      const t = new Tiler();
      

    Methods

    • Returns a GeoJSON FeatureCollection containing a Feature for each rectangular tile

      Parameters

      Returns FeatureCollection

      FeatureCollection containing a Feature for each rectangular tile

      Useful for displaying a tile grid for debugging.

      const t = new Tiler();
      const v = new Viewport();
      v.transform = { x: 256, y: 256, z: 1 };
      v.dimensions = [512, 512]; // entire world visible
      const result = t.getTiles(v);
      const gj = t.getGeoJSON(result); // returns a GeoJSON FeatureCollection
    • Returns a TileResult object which contains details about all the tiles covering the given viewport

      Parameters

      Returns TileResult

      tile result

      At zoom 0:

      +-------+ +85.0511
      | |
      | 0,0,0 |
      | |
      +-------+ -85.0511
      -180 +180

      const t0 = new Tiler();
      const v0 = new Viewport();
      v0.transform = { x: 128, y: 128, z: 0 };
      v0.dimensions = [256, 256]; // entire world visible
      const result = t0.getTiles(v0);

      At zoom 1:

      +-------+-------+ +85.0511
      | | |
      | 0,0,1 | 1,0,1 |
      | | |
      +-------+-------+ 0
      | | |
      | 0,1,1 | 1,1,1 |
      | | |
      +-------+-------+ -85.0511
      -180 0 +180

      const t1 = new Tiler();
      const v1 = new Viewport();
      v1.transform = { x: 256, y: 256, z: 1 };
      v1.dimensions = [512, 512]; // entire world visible
      const result = t1.getTiles(v1);

      At zoom 2:

      +-------+-------+-------+-------+ +85.0511
      | | | | |
      | 0,0,2 | 1,0,2 | 2,0,2 | 3,0,2 |
      | | | | |
      +-------+-------+-------+-------+ +66.5133
      | | | | |
      | 0,1,2 | 1,1,2 | 2,1,2 | 3,1,2 |
      | | | | |
      +-------+-------+-------+-------+ 0
      | | | | |
      | 0,2,2 | 1,2,2 | 2,2,2 | 3,2,2 |
      | | | | |
      +-------+-------+-------+-------+ -66.5133
      | | | | |
      | 0,3,2 | 1,3,2 | 2,3,2 | 3,3,2 |
      | | | | |
      +-------+-------+-------+-------+ -85.0511
      -180 -90 0 +90 +180

      const t2 = new Tiler();
      const v2 = new Viewport();
      v2.transform = { x: 512, y: 512, z: 2 };
      v2.dimensions = [1024, 1024]; // entire world visible
      const result = t2.getTiles(v2);
    • Sets/Gets the current tile margin (number to extend the rows/columns beyond those covering the viewport)

      Parameters

      • Optionalval: number

      Returns number | Tiler

      When an argument is passed, sets the tile margin and returns this for method chaining Returns the tile margin otherwise

      const t = new Tiler().margin(1);   // sets tile margin
      t.margin(); // gets tile margin - returns 1
    • Sets/Gets the current skipNullIsland value

      Parameters

      • Optionalval: boolean

      Returns boolean | Tiler

      When an argument is passed, sets the skipNullIsland value and returns this for method chaining Returns the skipNullIsland value otherwise

      When loading data from a tiled service, it is common for invalid data to be located around "Null Island", therefore it can be useful to skip loading these tiles

      const t = new Tiler().skipNullIsland(true);   // sets skipNullIsland value
      t.skipNullIsland(); // gets skipNullIsland value - returns true
    • Sets/Gets the current tileSize

      Parameters

      • Optionalval: number

        tile size value

      Returns number | Tiler

      When passed a numeric argument, sets the tile size and returns this for method chaining Returns the tile size otherwise

      const t = new Tiler().tileSize(512);   // sets tile size
      t.tileSize(); // gets tile size - returns 512
    • Sets/Gets the current zoomRange

      Parameters

      • Optionalmin: number
      • Optionalmax: number

      Returns Vec2 | Tiler

      When arguments are passed, sets the min/max zoom range and returns this for method chaining Returns the min/max zoom range otherwise

      const t = new Tiler().zoomRange(10, 20);   // sets min/max zoom range
      t.zoomRange(); // gets min/max zoom range - returns [10, 20]
    • Tests whether the given tile coordinate is near [0,0] (Null Island)

      Parameters

      • x: number
      • y: number
      • z: number

      Returns boolean

      true if near null island, false otherwise

      A tile is considered "near" if it >= z7 and around the center of the map within these or descendent tiles (roughly within about 2.8° of [0,0]).

      +---------+---------+
      | | |
      | 63,63,7 | 64,63,7 |
      | | |
      +-------[0,0]-------+
      | | |
      | 63,64,7 | 64,64,7 |
      | | |
      +---------+---------+
      Tiler.isNearNullIsland(31, 31, 6); // returns false (zoom 6)
      Tiler.isNearNullIsland(63, 65, 7); // returns false (south of Null Island region)

      Tiler.isNearNullIsland(63, 63, 7); // returns true
      Tiler.isNearNullIsland(127, 127, 8); // returns true