Index of every page on this site: llms.txt
All skills
gmi-software avatar

/react-native-better-clustering

@443959a
Run it yourself

Expert guide to react-native-better-clustering — a drop-in clustered MapView for react-native-maps backed by a C++ supercluster engine over Nitro/JSI. Use when installing, configuring, or debugging it; when clustering is slow, wrong, or flickering; when handling thousands of map markers; when migrating from react-native-map-clustering or react-native-clusterer; and when changing the library's TypeScript, C++, or Nitro specs. Also use before writing any performance claim about map clustering, pan, zoom, or marker frame rate.

  • 11 files
  • 102.9 KB
  • MIT
  • Updated 3 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/gmi-software/better-skills/react-native-better-clustering

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesaggregation.md

≈953 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Aggregation (clusterProperties)

Declarative numeric cluster properties. Sources: package/src/utils/clusterProperties.ts, packPoints.ts, Supercluster / useClusterer options, ReducerKind / C++ reducers in GeoUtils.hpp / ClusterEngineCore.

API recipes: api.md. Build/query algorithm: algo.md. Copies and v2 buffer layout: architecture.md.

Entry points

`clusterProperties` is supported by the lower-level clustering APIs,
but it is NOT a prop accepted by the root MapView compatibility API.
Entry clusterProperties
Supercluster / createClusterEngine (/engine) Yes — via SuperclusterOptions / native reducers
useClusterer / Clusterer (/hooks, /clusterer) Yes — options object
Root MapView / /compat No — clustererOptions only passes radius, maxZoom, minZoom, minPoints, extent, nodeSize

Do not write <MapView clusterProperties={...} />. Compat never reads that prop; TypeScript bypass does not enable it.

Shape (sum | min | max only)

{ source: string; key?: string; reduce: 'sum' | 'min' | 'max' }[]
  • source — dot path into leaf properties (numeric values only).
  • key — property name written onto cluster features; defaults to the last segment of source.
  • reduce — only 'sum' | 'min' | 'max'. No avg, count, median, map/reduce callbacks, or arbitrary JS reducers.

JS Mapbox supercluster allows arbitrary map/reduce functions. This port only runs declarative reducers in C++ (ReducerKind) so build does not hop to JS.

const [clusters] = useClusterer(data, dimensions, region, {
  clusterProperties: [
    { source: 'price', reduce: 'sum' },           // → properties.price
    { source: 'price', key: 'maxPrice', reduce: 'max' },
  ],
})
// cluster.properties.price / maxPrice on cluster features

Keep the clusterProperties array stable or memoized — option identity / clusterPropertiesKey triggers a full destroy + loadAsync rebuild (architecture.md, rendering.md).

Median (or other unsupported reducers) requires app-side logic or a new library design — not an unsupported option invent.

Pipeline

leaf properties (numeric, via source path)
      ↓  JS extractGeoJSONAggregationValues (clusterProperties.ts)
packed float64 values in v2 buffer
      ↓  setPoints → PointData.values
C++ build-time reduction (sum | min | max per reducer)
      ↓  values on ClusterNode / EngineClusterNode
mapped back onto cluster GeoJSON properties by key

Reduction runs during native hierarchy construction, not on each JS query. Aggregation adds packed values and per-node values storage — extra cost on build and memory (algo.md).

Non-numeric source values are not valid for native reducers; do not emulate an arbitrary reducer callback inside the native build path.

Packing (v2 buffer)

packPoints little-endian layouts (architecture.md):

  • v1 (no aggregation): uint32 count, then per point int32 index, float64 lat, float64 lng (20-byte stride).
  • v2 (values present): magic 0x4E4D4332 (PACK_POINTS_MAGIC_V2), count, numProps, then per point the v1 fields plus numProps float64s.

Buffer size ≈ 12 + n*(20+8p) for v2 with p properties. Invalid / malformed buffers: setPointsFromBuffer rejects; HybridObject throws. C++ coverage: testBufferV2Aggregation, testInvalidBufferRejected, testPropertyAggregationSumMinMax.

Headless createClusterEngine can take reducers: [] on setOptions with values already packed; high-level callers use clusterProperties on Supercluster / useClusterer which extract + pack for them.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 443959a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 3 months ago
Other metadata
metadata
{
  "package": "react-native-better-clustering",
  "version": "1.0.0",
  "commit": "7c7d659046a3d1bb8b7d4cb06a94f6e0d509862e",
  "verified": "2026-08-21",
  "repository": "https://github.com/gmi-software/react-native-better-clustering",
  "audience": "library users and library contributors",
  "tags": "react-native, clustering, maps, markers, geospatial, supercluster, nitro, jsi, cpp, performance, ios, android, expo"
}

README badge

README badge for gmi-software/better-skills/react-native-better-clustering