# GeoJSONOverlay

class in `3d-tiles-renderer/three/plugins`, extends `ImageOverlay`

```js
import { GeoJSONOverlay } from '3d-tiles-renderer/three/plugins';
```

Overlay that rasterizes a GeoJSON dataset onto 3D tile geometry. Features are drawn using the
Canvas 2D API at the tile's native resolution. Per-feature style overrides can be provided via
the `strokeStyle`, `fillStyle`, `strokeWidth`, and `pointRadius` properties on each GeoJSON
feature's `properties` object.

Example: Drawing GeoJSON borders over the globe

```js
import { TilesRenderer, GlobeControls } from '3d-tiles-renderer/three';
import { GeneratedSurfacePlugin, ImageOverlayPlugin, XYZTilesOverlay, GeoJSONOverlay } from '3d-tiles-renderer/three/plugins';

// scene, camera and renderer are initialized here

const URL = 'https://raw.githubusercontent.com/gkjohnson/three-geojson/v0.0.14/example/world.geojson';
const SATELLITE_URL = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}';

const tiles = new TilesRenderer();
tiles.registerPlugin( new GeneratedSurfacePlugin( {
	overlay: new XYZTilesOverlay( { url: SATELLITE_URL } ),
	applyOverlayTexture: true,
} ) );
tiles.registerPlugin( new ImageOverlayPlugin( {
	renderer,
	overlays: [ new GeoJSONOverlay( { url: URL, fillStyle: 'transparent' } ) ],
} ) );
tiles.setCamera( camera );
tiles.group.rotation.x = - Math.PI / 2;
scene.add( tiles.group );

camera.position.set( 0, 0, 1.75e7 );

const controls = new GlobeControls( scene, camera, renderer.domElement );
controls.setEllipsoid( tiles.ellipsoid, tiles.group );
controls.enableDamping = true;

renderer.setAnimationLoop( () => {

	controls.update();
	camera.updateMatrixWorld();
	tiles.setResolutionFromRenderer( camera, renderer );
	tiles.update();
	renderer.render( scene, camera );

} );
```

## Constructor

```js
new GeoJSONOverlay( options?: Object )
```

- `options`, `Object`, optional
  - `geojson`, `Object`, optional, default `null`: GeoJSON FeatureCollection or Feature object to render.
If not provided, `url` must be set so the data can be fetched on init.
  - `url`, `string`, optional, default `null`: URL to a GeoJSON file to fetch on initialization (used when
`geojson` is not supplied directly).
  - `resolution`, `number`, optional, default `256`: Canvas resolution (pixels) used when compositing tiles.
  - `getStyle`, `GeoJSONGetStyleCallback`, optional: Per-feature style callback. When provided, overrides `strokeStyle`, `fillStyle`, `strokeWidth`, and `pointRadius`.
  - `pointRadius`, `number`, optional, default `6`: Radius in pixels used to render Point features.
  - `strokeStyle`, `string`, optional, default `'white'`: Canvas stroke style for feature outlines.
  - `strokeWidth`, `number`, optional, default `2`: Stroke line width in pixels.
  - `fillStyle`, `string`, optional, default `'rgba( 255, 255, 255, 0.5 )'`: Canvas fill style for feature interiors.
  - `opacity`, `number`, optional, default `1`: Overlay opacity (0–1).
  - `color`, `number | Color`, optional, default `0xffffff`: Tint color.
  - `frame`, `Matrix4`, optional, default `null`: Planar projection frame. If null, cartographic projection is used.
  - `preprocessURL`, `function`, optional, default `null`: URL rewriting callback.
  - `alphaMask`, `boolean`, optional, default `false`: Use alpha channel as a surface mask.
  - `alphaInvert`, `boolean`, optional, default `false`: Invert the alpha channel.
