---
title: "default | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Class default

##### Index

### Constructors[](#constructors)

[constructor](#constructor)

### Properties[](#properties)

[ArrayType](#arraytype) [coords](#coords) [data](#data) [ids](#ids) [IndexArrayType](#indexarraytype) [nodeSize](#nodesize) [numItems](#numitems)

### Methods[](#methods)

[add](#add) [finish](#finish) [range](#range) [within](#within) [withinInto](#withininto) [from](#from)

## Constructors[](#constructors-1)

### constructor[](#constructor)

-   new default(  
        numItems: number,  
        nodeSize?: number,  
        ArrayType?: [TypedArrayConstructor](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.TypedArrayConstructor/),  
        ArrayBufferType?: ArrayBufferConstructor | [SharedArrayBufferConstructor](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SharedArrayBufferConstructor/),  
        data?: [ArrayBufferLike](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ArrayBufferLike/),  
    ): default[](#constructordefault)
    
    Creates an index that will hold a given number of items.
    
    #### Parameters
    
    -   numItems: number
    -   `Optional`nodeSize: number
        
        Size of the KD-tree node (64 by default).
        
    -   `Optional`ArrayType: [TypedArrayConstructor](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.TypedArrayConstructor/)
        
        The array type used for coordinates storage (`Float64Array` by default).
        
    -   `Optional`ArrayBufferType: ArrayBufferConstructor | [SharedArrayBufferConstructor](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.SharedArrayBufferConstructor/)
        
        The array buffer type used for storage (`ArrayBuffer` by default).
        
    -   `Optional`data: [ArrayBufferLike](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ArrayBufferLike/)
        
        (For internal use only)
        
    
    #### Returns default
    

## Properties[](#properties-1)

### ArrayType[](#arraytype)

ArrayType: [TypedArrayConstructor](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.TypedArrayConstructor/)

### coords[](#coords)

coords:  
    | Float32Array<ArrayBuffer\>  
    | Uint8Array<ArrayBuffer\>  
    | Float64Array<ArrayBuffer\>  
    | Uint32Array<ArrayBuffer\>  
    | Uint16Array<ArrayBuffer\>  
    | Int8Array<ArrayBuffer\>  
    | Uint8ClampedArray<ArrayBuffer\>  
    | Int16Array<ArrayBuffer\>  
    | Int32Array<ArrayBuffer\>

### data[](#data)

data: [ArrayBufferLike](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ArrayBufferLike/)

### ids[](#ids)

ids: Uint32Array<ArrayBuffer\> | Uint16Array<ArrayBuffer\>

### IndexArrayType[](#indexarraytype)

IndexArrayType: Uint16ArrayConstructor | Uint32ArrayConstructor

### nodeSize[](#nodesize)

nodeSize: number

### numItems[](#numitems)

numItems: number

## Methods[](#methods-1)

### add[](#add)

-   add(x: number, y: number): number[](#add-1)
    
    Add a point to the index.
    
    #### Parameters
    
    -   x: number
    -   y: number
    
    #### Returns number
    
    An incremental index associated with the added item (starting from `0`).
    

### finish[](#finish)

-   finish(): this[](#finish-1)
    
    Perform indexing of the added points.
    
    #### Returns this
    

### range[](#range)

-   range(minX: number, minY: number, maxX: number, maxY: number): number\[\][](#range-1)
    
    Search the index for items within a given bounding box.
    
    #### Parameters
    
    -   minX: number
    -   minY: number
    -   maxX: number
    -   maxY: number
    
    #### Returns number\[\]
    
    An array of indices correponding to the found items.
    

### within[](#within)

-   within(qx: number, qy: number, r: number): number\[\][](#within-1)
    
    Search the index for items within a given radius.
    
    #### Parameters
    
    -   qx: number
    -   qy: number
    -   r: number
        
        Query radius.
        
    
    #### Returns number\[\]
    
    An array of indices correponding to the found items.
    

### withinInto[](#withininto)

-   withinInto(  
        qx: number,  
        qy: number,  
        r: number,  
        out: number\[\] | [TypedArray](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.TypedArray/),  
    ): number[](#withininto-1)
    
    Search the index for items within a given radius, writing matching ids into `out` via indexed assignment (`out[i] = id`). Accepts any indexed-writable container — a typed array sized to the expected upper bound (allocation-free, fast) or a plain `Array` (which will grow as needed). Returns the number of matches written.
    
    #### Parameters
    
    -   qx: number
    -   qy: number
    -   r: number
        
        Query radius.
        
    -   out: number\[\] | [TypedArray](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.TypedArray/)
        
        Container to write matching ids into.
        
    
    #### Returns number
    
    The number of matches written to `out`.
    

### `Static`from[](#from)

-   from(data: [ArrayBufferLike](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ArrayBufferLike/)): default[](#from-1)
    
    Creates an index from raw `ArrayBuffer` data.
    
    #### Parameters
    
    -   data: [ArrayBufferLike](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.ArrayBufferLike/)
    
    #### Returns default
