@foodmarketmaker/mapag 0.0.9 → 0.0.10
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';
|
|
@@ -229,14 +229,12 @@ class Styles {
|
|
|
229
229
|
this.saveCustomSourcesAndLayers();
|
|
230
230
|
this.map.once("styledata", () => {
|
|
231
231
|
setTimeout(() => {
|
|
232
|
-
console.log('=== MAP ONCE ===');
|
|
233
232
|
// Update current basemap tracking from cached style
|
|
234
233
|
this.updateBasemapTracking(styleData);
|
|
235
234
|
// Then restore the custom sources/layers
|
|
236
235
|
this.restoreCustomSourcesAndLayers();
|
|
237
236
|
}, 100);
|
|
238
237
|
});
|
|
239
|
-
console.log('=== MAP SETTING STYLE ===');
|
|
240
238
|
this.map.setStyle(styleData.url);
|
|
241
239
|
this.style.set(styleData);
|
|
242
240
|
this.currentStyleCode = styleData.code;
|
|
@@ -295,9 +293,6 @@ class Styles {
|
|
|
295
293
|
saveCustomSourcesAndLayers() {
|
|
296
294
|
if (!this.map)
|
|
297
295
|
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
296
|
// Reset custom sources and layers
|
|
302
297
|
this.customSourcesAndLayers = {
|
|
303
298
|
sources: {},
|
|
@@ -305,31 +300,20 @@ class Styles {
|
|
|
305
300
|
image: {},
|
|
306
301
|
};
|
|
307
302
|
const sources = this.map.getStyle().sources;
|
|
308
|
-
console.log('All current sources:', Object.keys(sources));
|
|
309
303
|
for (const [sourceId, source] of Object.entries(sources)) {
|
|
310
304
|
// Only save sources that are NOT part of the basemap
|
|
311
305
|
if (!this.currentBasemapSources.has(sourceId)) {
|
|
312
|
-
console.log('Saving custom source:', sourceId);
|
|
313
306
|
this.customSourcesAndLayers.sources[sourceId] = source;
|
|
314
307
|
}
|
|
315
308
|
else {
|
|
316
|
-
console.log('Skipping basemap source:', sourceId);
|
|
317
309
|
}
|
|
318
310
|
}
|
|
319
311
|
const layers = this.map.getStyle().layers;
|
|
320
|
-
console.log('All current layers:', layers.map(l => l.id));
|
|
321
312
|
for (const layer of layers) {
|
|
322
|
-
if (layer.id === 'area-fill') {
|
|
323
|
-
console.log('TRACKING: AREA FILL');
|
|
324
|
-
}
|
|
325
313
|
// Only save layers that are NOT part of the basemap
|
|
326
314
|
if (!this.currentBasemapLayers.has(layer.id)) {
|
|
327
|
-
console.log('Saving custom layer:', layer.id);
|
|
328
315
|
this.customSourcesAndLayers.layers.push(layer);
|
|
329
316
|
}
|
|
330
|
-
else {
|
|
331
|
-
console.log('Skipping basemap layer:', layer.id);
|
|
332
|
-
}
|
|
333
317
|
}
|
|
334
318
|
const allImageIDs = this.map.listImages();
|
|
335
319
|
const customIDs = allImageIDs.filter((id) => id.startsWith("customImg-"));
|
|
@@ -343,50 +327,30 @@ class Styles {
|
|
|
343
327
|
}
|
|
344
328
|
});
|
|
345
329
|
}
|
|
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
330
|
}
|
|
351
331
|
restoreCustomSourcesAndLayers() {
|
|
352
332
|
if (!this.map)
|
|
353
333
|
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
334
|
// Check what's actually on the map RIGHT NOW
|
|
358
335
|
const currentSources = Object.keys(this.map.getStyle().sources || {});
|
|
359
336
|
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
337
|
// Add custom sources first
|
|
363
338
|
for (const [sourceId, source] of Object.entries(this.customSourcesAndLayers.sources)) {
|
|
364
339
|
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
340
|
}
|
|
372
341
|
// Add custom layers second
|
|
373
342
|
for (const layer of this.customSourcesAndLayers.layers) {
|
|
374
343
|
AddLayer(this.map, layer);
|
|
375
|
-
if (layer.id === 'area-fill') {
|
|
376
|
-
console.log('FOLUND: AREA FILL');
|
|
377
|
-
}
|
|
378
344
|
}
|
|
379
345
|
// Add all custom images
|
|
380
346
|
for (const [imageId, image] of Object.entries(this.customSourcesAndLayers.image)) {
|
|
381
347
|
try {
|
|
382
|
-
console.log('Adding custom image:', imageId);
|
|
383
348
|
this.map.addImage(imageId, image.data);
|
|
384
349
|
}
|
|
385
350
|
catch (error) {
|
|
386
351
|
console.error('Error adding image', imageId, ':', error);
|
|
387
352
|
}
|
|
388
353
|
}
|
|
389
|
-
console.log('=== RESTORE COMPLETE ===');
|
|
390
354
|
}
|
|
391
355
|
}
|
|
392
356
|
const MapStyles = {
|
|
@@ -481,8 +445,6 @@ class BasemapSelect {
|
|
|
481
445
|
}
|
|
482
446
|
// Try different path approaches for debugging
|
|
483
447
|
const originalPath = this.styleData.image;
|
|
484
|
-
console.log('Original image path:', originalPath);
|
|
485
|
-
console.log('StyleData:', this.styleData);
|
|
486
448
|
// Return the original path first to test
|
|
487
449
|
return `url(${originalPath})`;
|
|
488
450
|
}
|
|
@@ -577,7 +539,6 @@ class BasemapSelectMenu {
|
|
|
577
539
|
}
|
|
578
540
|
}
|
|
579
541
|
selectStyle(style) {
|
|
580
|
-
console.log('Style selected from popover:', style.name);
|
|
581
542
|
const s = this.map().styles;
|
|
582
543
|
if (s) {
|
|
583
544
|
s.style.set(style);
|
|
@@ -636,11 +597,11 @@ class BasemapSelectMenu {
|
|
|
636
597
|
</div>
|
|
637
598
|
</div>
|
|
638
599
|
</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"] }] });
|
|
600
|
+
`, 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
601
|
}
|
|
641
602
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: BasemapSelectMenu, decorators: [{
|
|
642
603
|
type: Component,
|
|
643
|
-
args: [{ selector: 'mapag-basemap-select-menu', imports: [CommonModule, BasemapSelect], template: `
|
|
604
|
+
args: [{ selector: 'mapag-basemap-select-menu', imports: [CommonModule, BasemapSelect], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
644
605
|
<div class="basemap-container"
|
|
645
606
|
(mouseenter)="showPopover()"
|
|
646
607
|
(mouseleave)="hidePopover()"
|
|
@@ -12838,7 +12799,6 @@ class MapboxMapperGroup {
|
|
|
12838
12799
|
svc;
|
|
12839
12800
|
mappers = new Map();
|
|
12840
12801
|
onStyleChange(map, svc) {
|
|
12841
|
-
console.log('=== MAP ON STYLE CHANGE - MapboxMapperGroup ===');
|
|
12842
12802
|
this.mappers.forEach((mapper) => {
|
|
12843
12803
|
if (mapper.onStyleChange) {
|
|
12844
12804
|
mapper.onStyleChange(map, svc);
|
|
@@ -12847,7 +12807,7 @@ class MapboxMapperGroup {
|
|
|
12847
12807
|
}
|
|
12848
12808
|
set(name, mapper) {
|
|
12849
12809
|
if (mapper == undefined) {
|
|
12850
|
-
|
|
12810
|
+
return;
|
|
12851
12811
|
}
|
|
12852
12812
|
this.mappers.set(name, mapper);
|
|
12853
12813
|
if (this.map && this.svc) {
|
|
@@ -12910,7 +12870,6 @@ class StandardLayersMapper {
|
|
|
12910
12870
|
static POINTS = 'points';
|
|
12911
12871
|
map;
|
|
12912
12872
|
onStyleChange(map, svc) {
|
|
12913
|
-
console.log('=== MAP ON STYLE CHANGE - StandardLayersMapper ===');
|
|
12914
12873
|
this.onReady(map, svc);
|
|
12915
12874
|
}
|
|
12916
12875
|
onReady(map, svc) {
|
|
@@ -13003,7 +12962,6 @@ class AreaMapperMapper {
|
|
|
13003
12962
|
}
|
|
13004
12963
|
onStyleChange(map, svc) {
|
|
13005
12964
|
// this.onReady(map, svc);
|
|
13006
|
-
console.log('=== MAP ON STYLE CHANGE - AreaMapperMapper ===');
|
|
13007
12965
|
}
|
|
13008
12966
|
onReady(map, svc) {
|
|
13009
12967
|
this.map = map;
|
|
@@ -14027,7 +13985,6 @@ class MapAreaSelectComponent {
|
|
|
14027
13985
|
// this.m.areaType = this.areaType
|
|
14028
13986
|
this.areaTypeSrc = Layers.FindVector(this.areaType);
|
|
14029
13987
|
if (!this.areaTypeSrc) {
|
|
14030
|
-
console.warn('MapAreaSelectComponent: No source found for area type ', this.areaType);
|
|
14031
13988
|
return;
|
|
14032
13989
|
}
|
|
14033
13990
|
// Initialize the mapper
|
|
@@ -14125,11 +14082,6 @@ class MapComponent {
|
|
|
14125
14082
|
ngOnDestroy() {
|
|
14126
14083
|
this.styles.destroy();
|
|
14127
14084
|
}
|
|
14128
|
-
layerExists(map, layerId) {
|
|
14129
|
-
if (map.getLayer(layerId) !== undefined) {
|
|
14130
|
-
console.log(`Layer ${layerId} already exists`);
|
|
14131
|
-
}
|
|
14132
|
-
}
|
|
14133
14085
|
initializeMap() {
|
|
14134
14086
|
this.zone.runOutsideAngular(() => {
|
|
14135
14087
|
const container = this.mapContainer();
|
|
@@ -14637,10 +14589,15 @@ class HardinessMapper {
|
|
|
14637
14589
|
over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
|
|
14638
14590
|
settings = signal(new HardinessSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
|
|
14639
14591
|
async onStyleChange(map, svc) {
|
|
14640
|
-
console.log('=== MAP ON STYLE CHANGE - MapboxMapperGroup ===');
|
|
14641
14592
|
// await this.onReady(map, svc);
|
|
14642
14593
|
}
|
|
14643
|
-
constructor() {
|
|
14594
|
+
constructor(settings) {
|
|
14595
|
+
if (settings) {
|
|
14596
|
+
this.settings.set({
|
|
14597
|
+
...this.settings(),
|
|
14598
|
+
...settings
|
|
14599
|
+
});
|
|
14600
|
+
}
|
|
14644
14601
|
const _ = effect(() => {
|
|
14645
14602
|
const settings = this.settings();
|
|
14646
14603
|
// this._update(settings);
|
|
@@ -14699,7 +14656,7 @@ class HardinessMapper {
|
|
|
14699
14656
|
}
|
|
14700
14657
|
}
|
|
14701
14658
|
update(newSettings) {
|
|
14702
|
-
this.settings.set({ ...newSettings });
|
|
14659
|
+
this.settings.set({ ...this.settings(), ...newSettings });
|
|
14703
14660
|
}
|
|
14704
14661
|
_update(settings) {
|
|
14705
14662
|
if (!this.map) {
|
|
@@ -14949,14 +14906,20 @@ class WatershedMapper {
|
|
|
14949
14906
|
current = null;
|
|
14950
14907
|
currentFeatureID = undefined;
|
|
14951
14908
|
over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
|
|
14952
|
-
constructor() {
|
|
14909
|
+
constructor(settings) {
|
|
14910
|
+
if (settings) {
|
|
14911
|
+
this.settings.set({
|
|
14912
|
+
...this.settings(),
|
|
14913
|
+
...settings
|
|
14914
|
+
});
|
|
14915
|
+
}
|
|
14953
14916
|
const _ = effect(() => {
|
|
14954
14917
|
const settings = this.settings();
|
|
14955
14918
|
this._update(settings);
|
|
14956
14919
|
}, ...(ngDevMode ? [{ debugName: "_" }] : []));
|
|
14957
14920
|
}
|
|
14958
14921
|
update(settings) {
|
|
14959
|
-
this.settings.set({ ...settings });
|
|
14922
|
+
this.settings.set({ ...this.settings(), ...settings });
|
|
14960
14923
|
}
|
|
14961
14924
|
_update(settings) {
|
|
14962
14925
|
if (!this.map) {
|