maplibre-gl-raster 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/{RasterControl-CGsK4CN7.js → RasterControl-yo9x-ULo.js} +81 -9
- package/dist/{RasterControl-CGsK4CN7.js.map → RasterControl-yo9x-ULo.js.map} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/maplibre-gl-raster.css +87 -0
- package/dist/react.mjs +1 -1
- package/dist/types/index.d.ts +30 -0
- package/dist/types/react.d.ts +30 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -114,6 +114,9 @@ The main control class implementing MapLibre's `IControl` interface.
|
|
|
114
114
|
| `interleaved` | `boolean` | `true` | Render the deck.gl overlay interleaved with the basemap layers |
|
|
115
115
|
| `defaultUrl` | `string` | `''` | Prefills the Add data URL input (not loaded until the user clicks Load) |
|
|
116
116
|
| `autoLoad` | `boolean` | `false` | Load `defaultUrl` automatically when the control is added to the map |
|
|
117
|
+
| `sampleData` | `RasterSampleDataset[]` | - | Sample COGs offered as a "Load sample data" dropdown above the URL input; picking one fills the input (hidden when empty) |
|
|
118
|
+
| `sampleDataLabel` | `string` | `'Load sample data...'` | Placeholder shown in the sample-data dropdown |
|
|
119
|
+
| `closeOnOutsideClick` | `boolean` | `true` | Collapse the panel when clicking outside it; set `false` to close only via the header button |
|
|
117
120
|
| `engine` | `RenderEngine` | `'maplibre-gl-raster'` | Initial rendering backend; switchable at runtime from the panel |
|
|
118
121
|
|
|
119
122
|
#### Raster Methods
|
|
@@ -18369,6 +18369,7 @@ var LayerManager = class {
|
|
|
18369
18369
|
try {
|
|
18370
18370
|
const tiff = await this._deps.loadGeoTIFF(url);
|
|
18371
18371
|
if (this._destroyed || !this.getLayer(layer.id)) return layer.id;
|
|
18372
|
+
if (!tiff.isTiled) throw new Error("This GeoTIFF is striped, not tiled, so it cannot be streamed as map tiles. Convert it to a tiled Cloud-Optimized GeoTIFF (COG) first, for example with `rio cogeo create input.tif output.tif` or `gdal_translate input.tif output.tif -of COG`, then load the result.");
|
|
18372
18373
|
layer.geotiff = tiff;
|
|
18373
18374
|
layer.bandCount = tiff.count;
|
|
18374
18375
|
layer.bandNames = readBandNames(tiff);
|
|
@@ -19091,6 +19092,68 @@ var AddDataSection = class {
|
|
|
19091
19092
|
if (e.key === "Enter") submitUrl();
|
|
19092
19093
|
});
|
|
19093
19094
|
const urlRow = el("div", { className: "mlr-row" }, input, loadBtn);
|
|
19095
|
+
const samples = options.sampleData ?? [];
|
|
19096
|
+
let sampleRow;
|
|
19097
|
+
if (samples.length > 0) {
|
|
19098
|
+
const placeholder = options.sampleDataLabel ?? "Load sample data...";
|
|
19099
|
+
const triggerLabel = el("span", {
|
|
19100
|
+
className: "mlr-sample-trigger-label",
|
|
19101
|
+
text: placeholder
|
|
19102
|
+
});
|
|
19103
|
+
const trigger = el("button", {
|
|
19104
|
+
className: "mlr-sample-trigger",
|
|
19105
|
+
type: "button",
|
|
19106
|
+
ariaLabel: placeholder,
|
|
19107
|
+
attrs: {
|
|
19108
|
+
"aria-haspopup": "listbox",
|
|
19109
|
+
"aria-expanded": "false"
|
|
19110
|
+
}
|
|
19111
|
+
}, triggerLabel, el("span", {
|
|
19112
|
+
className: "mlr-sample-caret",
|
|
19113
|
+
text: "▾"
|
|
19114
|
+
}));
|
|
19115
|
+
const menu = el("div", {
|
|
19116
|
+
className: "mlr-sample-menu",
|
|
19117
|
+
attrs: { role: "listbox" }
|
|
19118
|
+
});
|
|
19119
|
+
menu.hidden = true;
|
|
19120
|
+
let menuOpen = false;
|
|
19121
|
+
const setMenuOpen = (open) => {
|
|
19122
|
+
menuOpen = open;
|
|
19123
|
+
menu.hidden = !open;
|
|
19124
|
+
trigger.setAttribute("aria-expanded", String(open));
|
|
19125
|
+
trigger.classList.toggle("open", open);
|
|
19126
|
+
if (open) menu.firstElementChild?.focus();
|
|
19127
|
+
};
|
|
19128
|
+
for (const sample of samples) {
|
|
19129
|
+
const option = el("button", {
|
|
19130
|
+
className: "mlr-sample-option",
|
|
19131
|
+
type: "button",
|
|
19132
|
+
text: sample.label,
|
|
19133
|
+
title: sample.url,
|
|
19134
|
+
attrs: { role: "option" }
|
|
19135
|
+
});
|
|
19136
|
+
option.addEventListener("click", () => {
|
|
19137
|
+
setMenuOpen(false);
|
|
19138
|
+
trigger.focus();
|
|
19139
|
+
input.value = sample.url;
|
|
19140
|
+
loadBtn.disabled = input.value.trim().length === 0;
|
|
19141
|
+
});
|
|
19142
|
+
menu.appendChild(option);
|
|
19143
|
+
}
|
|
19144
|
+
trigger.addEventListener("click", () => setMenuOpen(!menuOpen));
|
|
19145
|
+
sampleRow = el("div", { className: "mlr-sample-row" }, trigger, menu);
|
|
19146
|
+
sampleRow.addEventListener("keydown", (e) => {
|
|
19147
|
+
if (e.key === "Escape" && menuOpen) {
|
|
19148
|
+
setMenuOpen(false);
|
|
19149
|
+
trigger.focus();
|
|
19150
|
+
}
|
|
19151
|
+
});
|
|
19152
|
+
sampleRow.addEventListener("focusout", (e) => {
|
|
19153
|
+
const next = e.relatedTarget;
|
|
19154
|
+
if (!next || !sampleRow.contains(next)) setMenuOpen(false);
|
|
19155
|
+
});
|
|
19156
|
+
}
|
|
19094
19157
|
const fileInput = el("input", {
|
|
19095
19158
|
type: "file",
|
|
19096
19159
|
ariaLabel: "raster-file",
|
|
@@ -19133,7 +19196,7 @@ var AddDataSection = class {
|
|
|
19133
19196
|
this.el = el("div", { className: "mlr-section mlr-add-data" }, el("div", {
|
|
19134
19197
|
className: "mlr-section-title",
|
|
19135
19198
|
text: "Add data"
|
|
19136
|
-
}), urlRow, dropZone, beforeIdInput);
|
|
19199
|
+
}), ...sampleRow ? [sampleRow] : [], urlRow, dropZone, beforeIdInput);
|
|
19137
19200
|
}
|
|
19138
19201
|
};
|
|
19139
19202
|
//#endregion
|
|
@@ -20085,6 +20148,8 @@ var PanelUI = class {
|
|
|
20085
20148
|
this._engine = engine;
|
|
20086
20149
|
const addData = new AddDataSection({
|
|
20087
20150
|
initialUrl: options?.defaultUrl,
|
|
20151
|
+
sampleData: options?.sampleData,
|
|
20152
|
+
sampleDataLabel: options?.sampleDataLabel,
|
|
20088
20153
|
onAddUrl: (url, beforeId) => {
|
|
20089
20154
|
this._manager.addRaster(url, { beforeId }).catch(() => {});
|
|
20090
20155
|
},
|
|
@@ -20362,6 +20427,9 @@ var DEFAULT_OPTIONS = {
|
|
|
20362
20427
|
interleaved: true,
|
|
20363
20428
|
defaultUrl: "",
|
|
20364
20429
|
autoLoad: false,
|
|
20430
|
+
sampleData: [],
|
|
20431
|
+
sampleDataLabel: "Load sample data...",
|
|
20432
|
+
closeOnOutsideClick: true,
|
|
20365
20433
|
engine: "maplibre-gl-raster",
|
|
20366
20434
|
epsgResolver: createResilientEpsgResolver()
|
|
20367
20435
|
};
|
|
@@ -20449,6 +20517,8 @@ var RasterControl = class {
|
|
|
20449
20517
|
const autoLoading = this._options.autoLoad && !!this._options.defaultUrl;
|
|
20450
20518
|
if (content) this._panelUI = new PanelUI(content, this._layerManager, {
|
|
20451
20519
|
defaultUrl: autoLoading ? "" : this._options.defaultUrl,
|
|
20520
|
+
sampleData: this._options.sampleData,
|
|
20521
|
+
sampleDataLabel: this._options.sampleDataLabel,
|
|
20452
20522
|
inspect: {
|
|
20453
20523
|
onToggle: () => this._inspector?.toggle(),
|
|
20454
20524
|
isActive: () => this._inspector?.enabled ?? false
|
|
@@ -20967,13 +21037,15 @@ var RasterControl = class {
|
|
|
20967
21037
|
* Setup event listeners for panel positioning and click-outside behavior.
|
|
20968
21038
|
*/
|
|
20969
21039
|
_setupEventListeners() {
|
|
20970
|
-
this.
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
21040
|
+
if (this._options.closeOnOutsideClick !== false) {
|
|
21041
|
+
this._clickOutsideHandler = (e) => {
|
|
21042
|
+
const target = e.target;
|
|
21043
|
+
if (!target.isConnected) return;
|
|
21044
|
+
if (this._inspector?.enabled) return;
|
|
21045
|
+
if (this._container && this._panel && !this._container.contains(target) && !this._panel.contains(target)) this.collapse();
|
|
21046
|
+
};
|
|
21047
|
+
document.addEventListener("click", this._clickOutsideHandler);
|
|
21048
|
+
}
|
|
20977
21049
|
this._resizeHandler = () => {
|
|
20978
21050
|
if (!this._state.collapsed) this._updatePanelPosition();
|
|
20979
21051
|
};
|
|
@@ -21046,4 +21118,4 @@ var RasterControl = class {
|
|
|
21046
21118
|
//#endregion
|
|
21047
21119
|
export { MAX_SAMPLE_TILES as C, createResilientEpsgResolver as D, readBandNames as E, statsForBand as S, percentileFromHistogram as T, COLORMAP_OPTIONS as _, isKnownColormap as a, colormaps_default as b, clamp as c, formatNumericValue as d, generateId as f, COLORMAP_NAMES as g, COLORMAP_DISPLAY_NAMES as h, PALETTE_COLORMAP as i, classNames as l, loadGeoTIFF as m, Colorbar as n, loadColormapSprite as o, throttle as p, readPixelValues as r, sampleColormapStops as s, RasterControl as t, debounce as u, COLORMAP_ROW_COUNT as v, computeAutoStats as w, autoRangeFor as x, colormapDisplayName as y };
|
|
21048
21120
|
|
|
21049
|
-
//# sourceMappingURL=RasterControl-
|
|
21121
|
+
//# sourceMappingURL=RasterControl-yo9x-ULo.js.map
|