@foodmarketmaker/mapag 0.0.8 → 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, ChangeDetectionStrategy } from '@angular/core';
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
- console.error('NO GOOD CAN COME FROM THIS');
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
@@ -14106,7 +14063,8 @@ class MapComponent {
14106
14063
  mapper = input(new MapboxMapperGroup(), ...(ngDevMode ? [{ debugName: "mapper" }] : []));
14107
14064
  mapContainer = viewChild('map', ...(ngDevMode ? [{ debugName: "mapContainer" }] : []));
14108
14065
  id = input('mapid', ...(ngDevMode ? [{ debugName: "id" }] : []));
14109
- onMap = output();
14066
+ onMapReady = output();
14067
+ mapReady = signal(undefined, ...(ngDevMode ? [{ debugName: "mapReady" }] : []));
14110
14068
  // accessToken = input.required<string>();
14111
14069
  // FontAwesome icons
14112
14070
  faPrint = faPrint;
@@ -14124,11 +14082,6 @@ class MapComponent {
14124
14082
  ngOnDestroy() {
14125
14083
  this.styles.destroy();
14126
14084
  }
14127
- layerExists(map, layerId) {
14128
- if (map.getLayer(layerId) !== undefined) {
14129
- console.log(`Layer ${layerId} already exists`);
14130
- }
14131
- }
14132
14085
  initializeMap() {
14133
14086
  this.zone.runOutsideAngular(() => {
14134
14087
  const container = this.mapContainer();
@@ -14174,7 +14127,8 @@ class MapComponent {
14174
14127
  std.onReady(map, this.svc);
14175
14128
  // Notify that the map is ready
14176
14129
  this.zone.runOutsideAngular(() => {
14177
- this.onMap.emit(map);
14130
+ this.onMapReady.emit(map);
14131
+ this.mapReady.set(map);
14178
14132
  });
14179
14133
  // Initialize the mapper(s)
14180
14134
  this.zone.runOutsideAngular(() => {
@@ -14200,7 +14154,7 @@ class MapComponent {
14200
14154
  this.map.triggerRepaint();
14201
14155
  }
14202
14156
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.10", ngImport: i0, type: MapComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
14203
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.10", type: MapComponent, isStandalone: true, selector: "mapag-map", inputs: { mapper: { classPropertyName: "mapper", publicName: "mapper", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onMap: "onMap" }, viewQueries: [{ propertyName: "mapContainer", first: true, predicate: ["map"], descendants: true, isSignal: true }], ngImport: i0, template: `
14157
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.10", type: MapComponent, isStandalone: true, selector: "mapag-map", inputs: { mapper: { classPropertyName: "mapper", publicName: "mapper", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onMapReady: "onMapReady" }, viewQueries: [{ propertyName: "mapContainer", first: true, predicate: ["map"], descendants: true, isSignal: true }], ngImport: i0, template: `
14204
14158
  <div class="mapcontainer" #map>
14205
14159
  @if (mapper().legends.length) { @for (legend of mapper().legends; track
14206
14160
  legend) {
@@ -14251,7 +14205,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
14251
14205
  </div>
14252
14206
  <ng-content></ng-content>
14253
14207
  `, styles: [":host{height:100%;position:relative;overflow:hidden}.mapcontainer{margin:0;padding:0;height:100%;width:100%}.legend{position:absolute;top:10px;right:10px;background:#fff;padding:10px;border-radius:5px;box-shadow:0 2px 4px #0003;z-index:1000}.buttons{position:absolute;top:10px;left:10px;z-index:1000}.buttons>button{border-radius:5px;border:1px solid #ccc;background:#fff;color:#333;padding:8px 12px;cursor:pointer;box-shadow:0 2px 4px #0003}.buttons>button:hover{background-color:#f0f0f0}.legend-row{display:grid;grid-template-columns:auto 1fr;gap:8px;padding:4px 0;align-items:center}.legend-title{font-weight:700;text-align:center;margin-bottom:8px}.legend-item{height:15px;width:15px;border:1px solid #ccc}\n"] }]
14254
- }], ctorParameters: () => [], propDecorators: { mapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "mapper", required: false }] }], mapContainer: [{ type: i0.ViewChild, args: ['map', { isSignal: true }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], onMap: [{ type: i0.Output, args: ["onMap"] }] } });
14208
+ }], ctorParameters: () => [], propDecorators: { mapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "mapper", required: false }] }], mapContainer: [{ type: i0.ViewChild, args: ['map', { isSignal: true }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], onMapReady: [{ type: i0.Output, args: ["onMapReady"] }] } });
14255
14209
  // Define map styles
14256
14210
  const mapStyles = {
14257
14211
  'carto-positron': {
@@ -14635,10 +14589,15 @@ class HardinessMapper {
14635
14589
  over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
14636
14590
  settings = signal(new HardinessSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
14637
14591
  async onStyleChange(map, svc) {
14638
- console.log('=== MAP ON STYLE CHANGE - MapboxMapperGroup ===');
14639
14592
  // await this.onReady(map, svc);
14640
14593
  }
14641
- constructor() {
14594
+ constructor(settings) {
14595
+ if (settings) {
14596
+ this.settings.set({
14597
+ ...this.settings(),
14598
+ ...settings
14599
+ });
14600
+ }
14642
14601
  const _ = effect(() => {
14643
14602
  const settings = this.settings();
14644
14603
  // this._update(settings);
@@ -14697,7 +14656,7 @@ class HardinessMapper {
14697
14656
  }
14698
14657
  }
14699
14658
  update(newSettings) {
14700
- this.settings.set({ ...newSettings });
14659
+ this.settings.set({ ...this.settings(), ...newSettings });
14701
14660
  }
14702
14661
  _update(settings) {
14703
14662
  if (!this.map) {
@@ -14947,14 +14906,20 @@ class WatershedMapper {
14947
14906
  current = null;
14948
14907
  currentFeatureID = undefined;
14949
14908
  over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
14950
- constructor() {
14909
+ constructor(settings) {
14910
+ if (settings) {
14911
+ this.settings.set({
14912
+ ...this.settings(),
14913
+ ...settings
14914
+ });
14915
+ }
14951
14916
  const _ = effect(() => {
14952
14917
  const settings = this.settings();
14953
14918
  this._update(settings);
14954
14919
  }, ...(ngDevMode ? [{ debugName: "_" }] : []));
14955
14920
  }
14956
14921
  update(settings) {
14957
- this.settings.set({ ...settings });
14922
+ this.settings.set({ ...this.settings(), ...settings });
14958
14923
  }
14959
14924
  _update(settings) {
14960
14925
  if (!this.map) {