# Leaflet.NJImagery

A small Leaflet plugin for browsing the New Jersey Office of GIS public aerial imagery collection. It provides 19 WMS layers from 1920 through 2020 and has no runtime dependency beyond Leaflet.

Documentation and a live demo are available at <https://maps.gisnj.com/tools/leaflet-nj-imagery/>.

## Browser usage

Load Leaflet, then the plugin:

```html
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="https://maps.gisnj.com/tools/leaflet-nj-imagery/leaflet-nj-imagery.js"></script>
```

Add the complete imagery picker. The 2020 natural imagery is selected by default:

```js
const map = L.map("map").setView([40.15, -74.7], 9);
L.control.njImagery({ collapsed: false }).addTo(map);
```

With npm, install `leaflet` and this package, then import it after Leaflet:

```js
const L = require("leaflet");
require("leaflet-nj-imagery");

L.tileLayer.njImagery("Natural2020").addTo(map);
```

Or add one layer directly:

```js
L.tileLayer.njImagery("Natural2019", { opacity: 0.8 }).addTo(map);
```

Use the layer collection with your own control or overlays:

```js
const baseLayers = L.NJImagery.layers({ maxZoom: 22 });
L.control.layers(baseLayers, myOverlays).addTo(map);
baseLayers["Natural 2020"].addTo(map);
```

## API

- `L.tileLayer.njImagery(id, options)` creates one `L.TileLayer.WMS`.
- `L.control.njImagery(options)` creates a standard Leaflet layer control. Use `defaultLayer: false` to avoid automatically adding a layer, or provide an imagery ID such as `"Infrared2020"`.
- `L.NJImagery.layers(options)` returns every layer keyed by its human-readable label.
- `L.NJImagery.catalog` exposes the imagery metadata.
- `L.NJImagery.find(id)` returns metadata for one imagery ID, or `null`.

All standard Leaflet WMS options are supported through the layer options object. The imagery is provided by the State of New Jersey; availability and coverage are controlled by that service. Applications should retain the attribution supplied by the plugin.

## Development

Run the dependency-free smoke tests with `npm test`. Leaflet is a peer dependency when the plugin is consumed from a package manager.

## License

Plugin code is MIT licensed. New Jersey imagery is subject to the source agency's terms.
