@foodmarketmaker/mapag 0.0.9 → 0.0.11
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { signal, effect, input, Input, Component, inject, NgZone, Injectable, output, viewChild
|
|
2
|
+
import { signal, effect, input, Input, Component, ChangeDetectionStrategy, inject, NgZone, Injectable, output, viewChild } from '@angular/core';
|
|
3
3
|
import { PMTiles, Protocol } from 'pmtiles';
|
|
4
4
|
import * as i1 from '@angular/common';
|
|
5
5
|
import { CommonModule } from '@angular/common';
|
|
@@ -225,25 +225,36 @@ class Styles {
|
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
227
|
// Fetch and cache the style definition if not already cached
|
|
228
|
-
await this.fetchAndCacheStyle(styleData);
|
|
228
|
+
const styleSpec = await this.fetchAndCacheStyle(styleData);
|
|
229
|
+
if (!styleSpec) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
229
232
|
this.saveCustomSourcesAndLayers();
|
|
230
233
|
this.map.once("styledata", () => {
|
|
231
234
|
setTimeout(() => {
|
|
232
|
-
console.log('=== MAP ONCE ===');
|
|
233
235
|
// Update current basemap tracking from cached style
|
|
234
236
|
this.updateBasemapTracking(styleData);
|
|
235
237
|
// Then restore the custom sources/layers
|
|
236
238
|
this.restoreCustomSourcesAndLayers();
|
|
237
239
|
}, 100);
|
|
238
240
|
});
|
|
239
|
-
|
|
240
|
-
this.map.setStyle(
|
|
241
|
+
// this.map.setStyle(styleData.url);
|
|
242
|
+
this.map.setStyle(styleSpec);
|
|
241
243
|
this.style.set(styleData);
|
|
242
244
|
this.currentStyleCode = styleData.code;
|
|
243
245
|
if (this.onStyleChange) {
|
|
244
246
|
this.onStyleChange(styleData);
|
|
245
247
|
}
|
|
246
248
|
}
|
|
249
|
+
async FetchStyleDefinition(styleData) {
|
|
250
|
+
const response = await fetch(styleData.url);
|
|
251
|
+
if (!response.ok) {
|
|
252
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
253
|
+
}
|
|
254
|
+
const styleSpec = await response.json();
|
|
255
|
+
styleSpec.glyphs = 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf';
|
|
256
|
+
return styleSpec;
|
|
257
|
+
}
|
|
247
258
|
async fetchAndCacheStyle(styleData) {
|
|
248
259
|
// Skip if already cached
|
|
249
260
|
if (this.styleCache[styleData.code]) {
|
|
@@ -260,6 +271,10 @@ class Styles {
|
|
|
260
271
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
261
272
|
}
|
|
262
273
|
const styleSpec = await response.json();
|
|
274
|
+
// Add Glyphs
|
|
275
|
+
if (!styleSpec.glyphs) {
|
|
276
|
+
styleSpec.glyphs = 'https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf';
|
|
277
|
+
}
|
|
263
278
|
// Extract source and layer IDs
|
|
264
279
|
const sourceIds = Object.keys(styleSpec.sources || {});
|
|
265
280
|
const layerIds = (styleSpec.layers || []).map((layer) => layer.id);
|
|
@@ -270,6 +285,7 @@ class Styles {
|
|
|
270
285
|
layers: layerIds
|
|
271
286
|
};
|
|
272
287
|
this.styleCache[styleData.code] = enhancedStyleData;
|
|
288
|
+
return styleSpec;
|
|
273
289
|
}
|
|
274
290
|
catch (error) {
|
|
275
291
|
console.error('Failed to fetch style definition for:', styleData.code, ':', error);
|
|
@@ -295,9 +311,6 @@ class Styles {
|
|
|
295
311
|
saveCustomSourcesAndLayers() {
|
|
296
312
|
if (!this.map)
|
|
297
313
|
return;
|
|
298
|
-
console.log('=== SAVING CUSTOM SOURCES AND LAYERS ===');
|
|
299
|
-
console.log('Current basemap sources:', Array.from(this.currentBasemapSources));
|
|
300
|
-
console.log('Current basemap layers:', Array.from(this.currentBasemapLayers));
|
|
301
314
|
// Reset custom sources and layers
|
|
302
315
|
this.customSourcesAndLayers = {
|
|
303
316
|
sources: {},
|
|
@@ -305,31 +318,20 @@ class Styles {
|
|
|
305
318
|
image: {},
|
|
306
319
|
};
|
|
307
320
|
const sources = this.map.getStyle().sources;
|
|
308
|
-
console.log('All current sources:', Object.keys(sources));
|
|
309
321
|
for (const [sourceId, source] of Object.entries(sources)) {
|
|
310
322
|
// Only save sources that are NOT part of the basemap
|
|
311
323
|
if (!this.currentBasemapSources.has(sourceId)) {
|
|
312
|
-
console.log('Saving custom source:', sourceId);
|
|
313
324
|
this.customSourcesAndLayers.sources[sourceId] = source;
|
|
314
325
|
}
|
|
315
326
|
else {
|
|
316
|
-
console.log('Skipping basemap source:', sourceId);
|
|
317
327
|
}
|
|
318
328
|
}
|
|
319
329
|
const layers = this.map.getStyle().layers;
|
|
320
|
-
console.log('All current layers:', layers.map(l => l.id));
|
|
321
330
|
for (const layer of layers) {
|
|
322
|
-
if (layer.id === 'area-fill') {
|
|
323
|
-
console.log('TRACKING: AREA FILL');
|
|
324
|
-
}
|
|
325
331
|
// Only save layers that are NOT part of the basemap
|
|
326
332
|
if (!this.currentBasemapLayers.has(layer.id)) {
|
|
327
|
-
console.log('Saving custom layer:', layer.id);
|
|
328
333
|
this.customSourcesAndLayers.layers.push(layer);
|
|
329
334
|
}
|
|
330
|
-
else {
|
|
331
|
-
console.log('Skipping basemap layer:', layer.id);
|
|
332
|
-
}
|
|
333
335
|
}
|
|
334
336
|
const allImageIDs = this.map.listImages();
|
|
335
337
|
const customIDs = allImageIDs.filter((id) => id.startsWith("customImg-"));
|
|
@@ -343,50 +345,30 @@ class Styles {
|
|
|
343
345
|
}
|
|
344
346
|
});
|
|
345
347
|
}
|
|
346
|
-
console.log('=== SAVE COMPLETE ===');
|
|
347
|
-
console.log('Saved sources:', Object.keys(this.customSourcesAndLayers.sources));
|
|
348
|
-
console.log('Saved layers:', this.customSourcesAndLayers.layers.map(l => l.id));
|
|
349
|
-
console.log('Saved images:', Object.keys(this.customSourcesAndLayers.image));
|
|
350
348
|
}
|
|
351
349
|
restoreCustomSourcesAndLayers() {
|
|
352
350
|
if (!this.map)
|
|
353
351
|
return;
|
|
354
|
-
console.log('=== RESTORING CUSTOM SOURCES AND LAYERS ===');
|
|
355
|
-
console.log('Sources to restore:', Object.keys(this.customSourcesAndLayers.sources));
|
|
356
|
-
console.log('Layers to restore:', this.customSourcesAndLayers.layers.map(l => l.id));
|
|
357
352
|
// Check what's actually on the map RIGHT NOW
|
|
358
353
|
const currentSources = Object.keys(this.map.getStyle().sources || {});
|
|
359
354
|
const currentLayers = (this.map.getStyle().layers || []).map(l => l.id);
|
|
360
|
-
console.log('ACTUAL current sources on map:', currentSources);
|
|
361
|
-
console.log('ACTUAL current layers on map:', currentLayers);
|
|
362
355
|
// Add custom sources first
|
|
363
356
|
for (const [sourceId, source] of Object.entries(this.customSourcesAndLayers.sources)) {
|
|
364
357
|
AddSource(this.map, sourceId, source);
|
|
365
|
-
// try {
|
|
366
|
-
// console.log('Adding custom source:', sourceId);
|
|
367
|
-
// this.map.addSource(sourceId, source);
|
|
368
|
-
// } catch (error) {
|
|
369
|
-
// console.error('Error adding source', sourceId, ':', error);
|
|
370
|
-
// }
|
|
371
358
|
}
|
|
372
359
|
// Add custom layers second
|
|
373
360
|
for (const layer of this.customSourcesAndLayers.layers) {
|
|
374
361
|
AddLayer(this.map, layer);
|
|
375
|
-
if (layer.id === 'area-fill') {
|
|
376
|
-
console.log('FOLUND: AREA FILL');
|
|
377
|
-
}
|
|
378
362
|
}
|
|
379
363
|
// Add all custom images
|
|
380
364
|
for (const [imageId, image] of Object.entries(this.customSourcesAndLayers.image)) {
|
|
381
365
|
try {
|
|
382
|
-
console.log('Adding custom image:', imageId);
|
|
383
366
|
this.map.addImage(imageId, image.data);
|
|
384
367
|
}
|
|
385
368
|
catch (error) {
|
|
386
369
|
console.error('Error adding image', imageId, ':', error);
|
|
387
370
|
}
|
|
388
371
|
}
|
|
389
|
-
console.log('=== RESTORE COMPLETE ===');
|
|
390
372
|
}
|
|
391
373
|
}
|
|
392
374
|
const MapStyles = {
|
|
@@ -481,8 +463,6 @@ class BasemapSelect {
|
|
|
481
463
|
}
|
|
482
464
|
// Try different path approaches for debugging
|
|
483
465
|
const originalPath = this.styleData.image;
|
|
484
|
-
console.log('Original image path:', originalPath);
|
|
485
|
-
console.log('StyleData:', this.styleData);
|
|
486
466
|
// Return the original path first to test
|
|
487
467
|
return `url(${originalPath})`;
|
|
488
468
|
}
|
|
@@ -577,7 +557,6 @@ class BasemapSelectMenu {
|
|
|
577
557
|
}
|
|
578
558
|
}
|
|
579
559
|
selectStyle(style) {
|
|
580
|
-
console.log('Style selected from popover:', style.name);
|
|
581
560
|
const s = this.map().styles;
|
|
582
561
|
if (s) {
|
|
583
562
|
s.style.set(style);
|
|
@@ -636,11 +615,11 @@ class BasemapSelectMenu {
|
|
|
636
615
|
</div>
|
|
637
616
|
</div>
|
|
638
617
|
</div>
|
|
639
|
-
`, isInline: true, styles: [":host{display:block;width:200px;height:80px;position:relative}.basemap-container{position:relative;width:100%;height:100%;border-radius:12px;background-size:cover;background-position:center;background-repeat:no-repeat;background-color:#f5f5f5;overflow:hidden;cursor:pointer;transition:transform .2s ease,box-shadow .2s ease;box-shadow:0 2px 8px #00000026;display:flex;align-items:center;justify-content:center}.basemap-container:hover{box-shadow:0 4px 16px #0003}.basemap-overlay{position:absolute;inset:0;background:linear-gradient(135deg,#0000001a,#0000004d);border-radius:12px;pointer-events:none}.basemap-title{position:relative;z-index:2;color:#fff;font-size:19px;font-weight:600;text-align:center;padding:8px 16px;background:#0000;border-radius:8px;-webkit-user-select:none;user-select:none;text-shadow:0 2px 4px rgba(0,0,0,.8);max-width:90%;word-wrap:break-word;line-height:1.2}.basemap-container:not([style*=\"background-image: url\"]){background:linear-gradient(135deg,#667eea,#764ba2)}.basemap-container:not([style*=\"background-image: url\"]) .basemap-overlay{background:#0000001a}.style-popover{padding:16px;background:#fff;border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid rgba(0,0,0,.1);opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s ease,visibility .2s ease;position:absolute;top:calc(100% + 8px);left:0;z-index:1000;max-width:90vw;max-height:80vh;overflow-y:auto;min-width:100%}.style-popover.show{opacity:1;visibility:visible;transform:translateY(0)}.style-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;min-width:380px;max-width:600px}.style-item{cursor:pointer;transition:transform .2s ease}.style-item:hover{transform:scale(1.05)}@media (max-width: 768px){.style-grid{grid-template-columns:repeat(auto-fill,minmax(200px,1fr));min-width:300px}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: BasemapSelect, selector: "mapag-basemap-select", inputs: ["styleData", "styles"] }] });
|
|
618
|
+
`, isInline: true, styles: [":host{display:block;width:200px;height:80px;position:relative}.basemap-container{position:relative;width:100%;height:100%;border-radius:12px;background-size:cover;background-position:center;background-repeat:no-repeat;background-color:#f5f5f5;overflow:hidden;cursor:pointer;transition:transform .2s ease,box-shadow .2s ease;box-shadow:0 2px 8px #00000026;display:flex;align-items:center;justify-content:center}.basemap-container:hover{box-shadow:0 4px 16px #0003}.basemap-overlay{position:absolute;inset:0;background:linear-gradient(135deg,#0000001a,#0000004d);border-radius:12px;pointer-events:none}.basemap-title{position:relative;z-index:2;color:#fff;font-size:19px;font-weight:600;text-align:center;padding:8px 16px;background:#0000;border-radius:8px;-webkit-user-select:none;user-select:none;text-shadow:0 2px 4px rgba(0,0,0,.8);max-width:90%;word-wrap:break-word;line-height:1.2}.basemap-container:not([style*=\"background-image: url\"]){background:linear-gradient(135deg,#667eea,#764ba2)}.basemap-container:not([style*=\"background-image: url\"]) .basemap-overlay{background:#0000001a}.style-popover{padding:16px;background:#fff;border-radius:12px;box-shadow:0 8px 32px #00000026;border:1px solid rgba(0,0,0,.1);opacity:0;visibility:hidden;transform:translateY(-10px);transition:opacity .2s ease,transform .2s ease,visibility .2s ease;position:absolute;top:calc(100% + 8px);left:0;z-index:1000;max-width:90vw;max-height:80vh;overflow-y:auto;min-width:100%}.style-popover.show{opacity:1;visibility:visible;transform:translateY(0)}.style-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;min-width:380px;max-width:600px}.style-item{cursor:pointer;transition:transform .2s ease}.style-item:hover{transform:scale(1.05)}@media (max-width: 768px){.style-grid{grid-template-columns:repeat(auto-fill,minmax(200px,1fr));min-width:300px}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: BasemapSelect, selector: "mapag-basemap-select", inputs: ["styleData", "styles"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
640
619
|
}
|
|
641
620
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasemapSelectMenu, decorators: [{
|
|
642
621
|
type: Component,
|
|
643
|
-
args: [{ selector: 'mapag-basemap-select-menu', imports: [CommonModule, BasemapSelect], template: `
|
|
622
|
+
args: [{ selector: 'mapag-basemap-select-menu', imports: [CommonModule, BasemapSelect], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
644
623
|
<div class="basemap-container"
|
|
645
624
|
(mouseenter)="showPopover()"
|
|
646
625
|
(mouseleave)="hidePopover()"
|
|
@@ -12838,7 +12817,6 @@ class MapboxMapperGroup {
|
|
|
12838
12817
|
svc;
|
|
12839
12818
|
mappers = new Map();
|
|
12840
12819
|
onStyleChange(map, svc) {
|
|
12841
|
-
console.log('=== MAP ON STYLE CHANGE - MapboxMapperGroup ===');
|
|
12842
12820
|
this.mappers.forEach((mapper) => {
|
|
12843
12821
|
if (mapper.onStyleChange) {
|
|
12844
12822
|
mapper.onStyleChange(map, svc);
|
|
@@ -12847,7 +12825,7 @@ class MapboxMapperGroup {
|
|
|
12847
12825
|
}
|
|
12848
12826
|
set(name, mapper) {
|
|
12849
12827
|
if (mapper == undefined) {
|
|
12850
|
-
|
|
12828
|
+
return;
|
|
12851
12829
|
}
|
|
12852
12830
|
this.mappers.set(name, mapper);
|
|
12853
12831
|
if (this.map && this.svc) {
|
|
@@ -12910,7 +12888,6 @@ class StandardLayersMapper {
|
|
|
12910
12888
|
static POINTS = 'points';
|
|
12911
12889
|
map;
|
|
12912
12890
|
onStyleChange(map, svc) {
|
|
12913
|
-
console.log('=== MAP ON STYLE CHANGE - StandardLayersMapper ===');
|
|
12914
12891
|
this.onReady(map, svc);
|
|
12915
12892
|
}
|
|
12916
12893
|
onReady(map, svc) {
|
|
@@ -13003,7 +12980,6 @@ class AreaMapperMapper {
|
|
|
13003
12980
|
}
|
|
13004
12981
|
onStyleChange(map, svc) {
|
|
13005
12982
|
// this.onReady(map, svc);
|
|
13006
|
-
console.log('=== MAP ON STYLE CHANGE - AreaMapperMapper ===');
|
|
13007
12983
|
}
|
|
13008
12984
|
onReady(map, svc) {
|
|
13009
12985
|
this.map = map;
|
|
@@ -14027,7 +14003,6 @@ class MapAreaSelectComponent {
|
|
|
14027
14003
|
// this.m.areaType = this.areaType
|
|
14028
14004
|
this.areaTypeSrc = Layers.FindVector(this.areaType);
|
|
14029
14005
|
if (!this.areaTypeSrc) {
|
|
14030
|
-
console.warn('MapAreaSelectComponent: No source found for area type ', this.areaType);
|
|
14031
14006
|
return;
|
|
14032
14007
|
}
|
|
14033
14008
|
// Initialize the mapper
|
|
@@ -14125,22 +14100,20 @@ class MapComponent {
|
|
|
14125
14100
|
ngOnDestroy() {
|
|
14126
14101
|
this.styles.destroy();
|
|
14127
14102
|
}
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
console.log(`Layer ${layerId} already exists`);
|
|
14131
|
-
}
|
|
14132
|
-
}
|
|
14133
|
-
initializeMap() {
|
|
14134
|
-
this.zone.runOutsideAngular(() => {
|
|
14103
|
+
async initializeMap() {
|
|
14104
|
+
this.zone.runOutsideAngular(async () => {
|
|
14135
14105
|
const container = this.mapContainer();
|
|
14136
|
-
let style =
|
|
14137
|
-
//
|
|
14106
|
+
// let style =
|
|
14107
|
+
// 'https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json';
|
|
14108
|
+
// // style = 'https://demotiles.maplibre.org/style.json'
|
|
14109
|
+
let style = await this.styles.FetchStyleDefinition(this.styles.style());
|
|
14138
14110
|
if (container) {
|
|
14139
14111
|
// @ts-ignore - Type conflict between different maplibre-gl versions
|
|
14140
14112
|
const map = new maplibregl.Map({
|
|
14141
14113
|
container: container.nativeElement,
|
|
14142
14114
|
// style: this.basemap(),
|
|
14143
|
-
style: this.styles.style().url, // Default style
|
|
14115
|
+
// style: this.styles.style().url, // Default style
|
|
14116
|
+
style: style, // Default style
|
|
14144
14117
|
center: [-98, 38.88],
|
|
14145
14118
|
minZoom: 1,
|
|
14146
14119
|
zoom: 3,
|
|
@@ -14637,10 +14610,15 @@ class HardinessMapper {
|
|
|
14637
14610
|
over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
|
|
14638
14611
|
settings = signal(new HardinessSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
|
|
14639
14612
|
async onStyleChange(map, svc) {
|
|
14640
|
-
console.log('=== MAP ON STYLE CHANGE - MapboxMapperGroup ===');
|
|
14641
14613
|
// await this.onReady(map, svc);
|
|
14642
14614
|
}
|
|
14643
|
-
constructor() {
|
|
14615
|
+
constructor(settings) {
|
|
14616
|
+
if (settings) {
|
|
14617
|
+
this.settings.set({
|
|
14618
|
+
...this.settings(),
|
|
14619
|
+
...settings
|
|
14620
|
+
});
|
|
14621
|
+
}
|
|
14644
14622
|
const _ = effect(() => {
|
|
14645
14623
|
const settings = this.settings();
|
|
14646
14624
|
// this._update(settings);
|
|
@@ -14699,7 +14677,7 @@ class HardinessMapper {
|
|
|
14699
14677
|
}
|
|
14700
14678
|
}
|
|
14701
14679
|
update(newSettings) {
|
|
14702
|
-
this.settings.set({ ...newSettings });
|
|
14680
|
+
this.settings.set({ ...this.settings(), ...newSettings });
|
|
14703
14681
|
}
|
|
14704
14682
|
_update(settings) {
|
|
14705
14683
|
if (!this.map) {
|
|
@@ -14941,28 +14919,47 @@ class VectorTileServerMapper {
|
|
|
14941
14919
|
// }
|
|
14942
14920
|
|
|
14943
14921
|
class WatershedMapper {
|
|
14922
|
+
static WBDHU2 = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/WBDHU2.pmtiles';
|
|
14923
|
+
static WBDHU4 = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/WBDHU4.pmtiles';
|
|
14924
|
+
static WBDHU6 = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/watershedhu6.pmtiles';
|
|
14925
|
+
static WBDHU8 = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/WBDHU8.pmtiles';
|
|
14926
|
+
static WBDHU10 = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/WBDHU10.pmtiles';
|
|
14927
|
+
static WBDHU12 = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/WBDHU12.pmtiles';
|
|
14944
14928
|
FILL_LAYER_ID = 'watershed-layer';
|
|
14945
14929
|
LINE_LAYER_ID = 'watershed-layer-line';
|
|
14930
|
+
LABEL_LAYER_ID = 'watershed-layer-label';
|
|
14946
14931
|
SOURCE_ID = 'watershedSource';
|
|
14947
14932
|
SOURCE_LAYER = 'watershedhu6';
|
|
14933
|
+
currentHU = 'HUC6';
|
|
14948
14934
|
settings = signal(new WatershedSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
|
|
14949
14935
|
current = null;
|
|
14950
14936
|
currentFeatureID = undefined;
|
|
14951
14937
|
over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
|
|
14952
|
-
constructor() {
|
|
14938
|
+
constructor(settings) {
|
|
14939
|
+
if (settings) {
|
|
14940
|
+
this.settings.set({
|
|
14941
|
+
...this.settings(),
|
|
14942
|
+
...settings
|
|
14943
|
+
});
|
|
14944
|
+
}
|
|
14953
14945
|
const _ = effect(() => {
|
|
14954
14946
|
const settings = this.settings();
|
|
14955
14947
|
this._update(settings);
|
|
14956
14948
|
}, ...(ngDevMode ? [{ debugName: "_" }] : []));
|
|
14957
14949
|
}
|
|
14958
14950
|
update(settings) {
|
|
14959
|
-
this.settings.set({ ...settings });
|
|
14951
|
+
this.settings.set({ ...this.settings(), ...settings });
|
|
14960
14952
|
}
|
|
14961
14953
|
_update(settings) {
|
|
14962
14954
|
if (!this.map) {
|
|
14963
14955
|
return;
|
|
14964
14956
|
}
|
|
14965
14957
|
const map = this.map;
|
|
14958
|
+
if (this.currentHU !== settings.hydrologicUnit) {
|
|
14959
|
+
this.clear();
|
|
14960
|
+
this.currentHU = settings.hydrologicUnit;
|
|
14961
|
+
this.create();
|
|
14962
|
+
}
|
|
14966
14963
|
if (settings.visible) {
|
|
14967
14964
|
map.setLayoutProperty(this.FILL_LAYER_ID, 'visibility', 'visible');
|
|
14968
14965
|
map.setLayoutProperty(this.LINE_LAYER_ID, 'visibility', 'visible');
|
|
@@ -14976,13 +14973,47 @@ class WatershedMapper {
|
|
|
14976
14973
|
map.setPaintProperty(this.LINE_LAYER_ID, 'line-color', settings.borderColor);
|
|
14977
14974
|
map.setPaintProperty(this.LINE_LAYER_ID, 'line-width', settings.borderWidth);
|
|
14978
14975
|
map.setPaintProperty(this.LINE_LAYER_ID, 'line-opacity', settings.borderOpacity);
|
|
14976
|
+
map.setLayoutProperty(this.LABEL_LAYER_ID, 'visibility', settings.labelsVisible ? 'visible' : 'none');
|
|
14977
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-size', settings.labelsSize);
|
|
14978
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-color', settings.labelsColor);
|
|
14979
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-halo-color', settings.labelsHaloColor);
|
|
14980
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-halo-width', settings.labelsHaloWidth);
|
|
14979
14981
|
}
|
|
14980
14982
|
create() {
|
|
14981
14983
|
if (!this.map) {
|
|
14982
14984
|
return;
|
|
14983
14985
|
}
|
|
14984
14986
|
const map = this.map;
|
|
14985
|
-
|
|
14987
|
+
let PMTILES_URL = WatershedMapper.WBDHU6;
|
|
14988
|
+
switch (this.settings().hydrologicUnit) {
|
|
14989
|
+
case 'HUC2':
|
|
14990
|
+
PMTILES_URL = WatershedMapper.WBDHU2;
|
|
14991
|
+
this.SOURCE_LAYER = 'WBDHU2';
|
|
14992
|
+
break;
|
|
14993
|
+
case 'HUC4':
|
|
14994
|
+
PMTILES_URL = WatershedMapper.WBDHU4;
|
|
14995
|
+
this.SOURCE_LAYER = 'WBDHU4';
|
|
14996
|
+
break;
|
|
14997
|
+
case 'HUC6':
|
|
14998
|
+
PMTILES_URL = WatershedMapper.WBDHU6;
|
|
14999
|
+
this.SOURCE_LAYER = 'watershedhu6';
|
|
15000
|
+
break;
|
|
15001
|
+
case 'HUC8':
|
|
15002
|
+
PMTILES_URL = WatershedMapper.WBDHU8;
|
|
15003
|
+
this.SOURCE_LAYER = 'WBDHU8';
|
|
15004
|
+
break;
|
|
15005
|
+
case 'HUC10':
|
|
15006
|
+
PMTILES_URL = WatershedMapper.WBDHU10;
|
|
15007
|
+
this.SOURCE_LAYER = 'WBDHU10';
|
|
15008
|
+
break;
|
|
15009
|
+
case 'HUC12':
|
|
15010
|
+
PMTILES_URL = WatershedMapper.WBDHU12;
|
|
15011
|
+
this.SOURCE_LAYER = 'WBDHU12';
|
|
15012
|
+
break;
|
|
15013
|
+
default:
|
|
15014
|
+
PMTILES_URL = WatershedMapper.WBDHU6;
|
|
15015
|
+
this.SOURCE_LAYER = 'watershedhu6';
|
|
15016
|
+
}
|
|
14986
15017
|
AddSource(map, this.SOURCE_ID, {
|
|
14987
15018
|
type: 'vector',
|
|
14988
15019
|
url: PMTILES_URL,
|
|
@@ -15000,6 +15031,15 @@ class WatershedMapper {
|
|
|
15000
15031
|
"source-layer": this.SOURCE_LAYER,
|
|
15001
15032
|
type: 'line',
|
|
15002
15033
|
}, StandardLayersMapper.POLYGONS_BACKGROUND);
|
|
15034
|
+
AddLayer(map, {
|
|
15035
|
+
id: this.LABEL_LAYER_ID,
|
|
15036
|
+
source: this.SOURCE_ID,
|
|
15037
|
+
"source-layer": this.SOURCE_LAYER,
|
|
15038
|
+
type: 'symbol',
|
|
15039
|
+
layout: {
|
|
15040
|
+
'text-field': ['get', 'name'],
|
|
15041
|
+
},
|
|
15042
|
+
}, StandardLayersMapper.POLYGONS_BACKGROUND);
|
|
15003
15043
|
this._update(this.settings());
|
|
15004
15044
|
if (!addedFill) {
|
|
15005
15045
|
return;
|
|
@@ -15043,6 +15083,7 @@ class WatershedMapper {
|
|
|
15043
15083
|
if (this.map) {
|
|
15044
15084
|
this.map.removeLayer(this.FILL_LAYER_ID);
|
|
15045
15085
|
this.map.removeLayer(this.LINE_LAYER_ID);
|
|
15086
|
+
this.map.removeLayer(this.LABEL_LAYER_ID);
|
|
15046
15087
|
this.map.removeSource(this.SOURCE_ID);
|
|
15047
15088
|
}
|
|
15048
15089
|
}
|
|
@@ -15053,12 +15094,18 @@ class WatershedMapper {
|
|
|
15053
15094
|
popup = null;
|
|
15054
15095
|
}
|
|
15055
15096
|
class WatershedSettings {
|
|
15097
|
+
hydrologicUnit = 'HUC6';
|
|
15056
15098
|
visible = true;
|
|
15057
15099
|
fillColor = '#0000ff';
|
|
15058
15100
|
fillOpacity = 0.1;
|
|
15059
15101
|
borderColor = '#01018bff';
|
|
15060
15102
|
borderWidth = 1;
|
|
15061
15103
|
borderOpacity = 1.0;
|
|
15104
|
+
labelsVisible = true;
|
|
15105
|
+
labelsSize = 12;
|
|
15106
|
+
labelsColor = '#000000';
|
|
15107
|
+
labelsHaloColor = '#ffffff';
|
|
15108
|
+
labelsHaloWidth = 1;
|
|
15062
15109
|
}
|
|
15063
15110
|
|
|
15064
15111
|
class HttpBoundaryLoader {
|