@foodmarketmaker/mapag 0.0.4 → 0.0.6

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 CHANGED
@@ -1,6 +1,54 @@
1
- # Mapag
1
+ # @foodmarketmaker/mapag
2
2
 
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.0.
3
+ Angular library for interactive maps with advanced geospatial features.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @foodmarketmaker/mapag
9
+ ```
10
+
11
+ ## Asset Setup
12
+
13
+ This library includes map preview images that need to be available in your application's assets folder.
14
+
15
+ ### Automatic Setup (Recommended)
16
+
17
+ The library includes a postinstall script that automatically copies assets to your project. The assets will be available at `assets/mapag/src/assets/`.
18
+
19
+ If the automatic setup fails, you can manually copy assets:
20
+
21
+ ```bash
22
+ npx mapag-copy-assets
23
+ ```
24
+
25
+ ### Manual Setup
26
+
27
+ If you need to manually copy the assets:
28
+
29
+ 1. Copy files from `node_modules/@foodmarketmaker/mapag/src/assets/`
30
+ 2. To your project's `src/assets/mapag/src/assets/` folder
31
+
32
+ ## Usage
33
+
34
+ ```typescript
35
+ import { MapagModule } from '@foodmarketmaker/mapag';
36
+
37
+ @NgModule({
38
+ imports: [MapagModule],
39
+ // ...
40
+ })
41
+ export class AppModule { }
42
+ ```
43
+
44
+ ## Features
45
+
46
+ - Interactive maps with MapLibre GL
47
+ - Multiple basemap styles
48
+ - Drawing tools (rectangles, polygons)
49
+ - Area selection components
50
+ - Geospatial data layers
51
+ - Customizable styling
4
52
 
5
53
  ## Code scaffolding
6
54
 
package/copy-assets.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ /**
7
+ * Copy mapag assets to the consuming application's assets folder
8
+ * This ensures the library's assets are available at runtime
9
+ */
10
+
11
+ function copyAssets() {
12
+ const sourceDir = path.join(__dirname, 'src', 'assets');
13
+ const targetDir = path.join(process.cwd(), 'src', 'assets', 'mapag', 'src', 'assets');
14
+
15
+ console.log('📦 Copying @foodmarketmaker/mapag assets...');
16
+ console.log('From:', sourceDir);
17
+ console.log('To:', targetDir);
18
+
19
+ try {
20
+ // Create target directory if it doesn't exist
21
+ fs.mkdirSync(targetDir, { recursive: true });
22
+
23
+ // Copy all files from source to target
24
+ const files = fs.readdirSync(sourceDir);
25
+ let copiedCount = 0;
26
+
27
+ files.forEach(file => {
28
+ const sourcePath = path.join(sourceDir, file);
29
+ const targetPath = path.join(targetDir, file);
30
+
31
+ if (fs.statSync(sourcePath).isFile()) {
32
+ fs.copyFileSync(sourcePath, targetPath);
33
+ copiedCount++;
34
+ console.log(`✅ Copied: ${file}`);
35
+ }
36
+ });
37
+
38
+ console.log(`🎉 Successfully copied ${copiedCount} asset files!`);
39
+ console.log('💡 Assets are now available at: assets/mapag/src/assets/');
40
+
41
+ } catch (error) {
42
+ console.error('❌ Error copying assets:', error.message);
43
+ console.log('⚠️ You may need to manually copy assets from node_modules/@foodmarketmaker/mapag/src/assets/');
44
+ process.exit(1);
45
+ }
46
+ }
47
+
48
+ // Run if called directly
49
+ if (require.main === module) {
50
+ copyAssets();
51
+ }
52
+
53
+ module.exports = { copyAssets };
@@ -32,16 +32,18 @@ function SaveMap(map) {
32
32
  }
33
33
  function AddLayer(map, layer, afterId) {
34
34
  if (!map)
35
- return;
35
+ return false;
36
36
  try {
37
37
  if (map.getLayer(layer.id)) {
38
38
  console.log(`Layer ${layer.id} already exists`);
39
- return;
39
+ return false;
40
40
  }
41
41
  map.addLayer(layer, afterId);
42
+ return true;
42
43
  }
43
44
  catch (error) {
44
45
  console.debug(`Error adding layer ${layer.id}`);
46
+ return false;
45
47
  }
46
48
  }
47
49
  function RemoveLayer(map, layerId) {
@@ -61,7 +63,6 @@ function AddSource(map, sourceId, source) {
61
63
  return;
62
64
  try {
63
65
  if (map.getSource(sourceId)) {
64
- console.log(`Source ${sourceId} already exists`);
65
66
  return;
66
67
  }
67
68
  map.addSource(sourceId, source);
@@ -14169,6 +14170,7 @@ class MapComponent {
14169
14170
  this.svc.setMapper(mapper);
14170
14171
  this.selectionSvc.setMap(this.map);
14171
14172
  this.selectionSvc.setMapper(mapper);
14173
+ this.mapper().onReady(this.map, this.svc);
14172
14174
  this.map.addControl(new maplibregl.NavigationControl());
14173
14175
  });
14174
14176
  }
@@ -14601,118 +14603,223 @@ class CensusTractMapper {
14601
14603
  };
14602
14604
  }
14603
14605
 
14606
+ class LayerSettings {
14607
+ visible = true;
14608
+ }
14609
+ class PolygonLayerSettings extends LayerSettings {
14610
+ fillColor = '#888888';
14611
+ fillOpacity = 0.5;
14612
+ opacity = 0.7;
14613
+ borderColor = '#ffffff';
14614
+ borderWidth = 0.5;
14615
+ borderOpacity = 0.8;
14616
+ }
14617
+ class DiscreteColors {
14618
+ colors = {};
14619
+ }
14620
+
14604
14621
  class HardinessMapper {
14622
+ LAYER_ID = 'hardiness-layer';
14623
+ SOURCE_ID = 'hardinessSource';
14624
+ SOURCE_LAYER = 'hardiness2023';
14625
+ PMTILES_URL = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/hardiness2023.pmtiles';
14605
14626
  current = null;
14606
14627
  currentFeatureID = undefined;
14607
14628
  over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
14629
+ settings = signal(new HardinessSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
14608
14630
  async onStyleChange(map, svc) {
14609
14631
  console.log('=== MAP ON STYLE CHANGE - MapboxMapperGroup ===');
14610
14632
  // await this.onReady(map, svc);
14611
14633
  }
14612
- async onReady(map, svc) {
14613
- this.map = map;
14614
- const PMTILES_URL = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/hardiness2023.pmtiles';
14634
+ constructor() {
14635
+ const _ = effect(() => {
14636
+ const settings = this.settings();
14637
+ this._update(settings);
14638
+ }, ...(ngDevMode ? [{ debugName: "_" }] : []));
14639
+ }
14640
+ async create() {
14641
+ if (!this.map) {
14642
+ return;
14643
+ }
14644
+ const map = this.map;
14615
14645
  // Method 1: Get available layers from PMTiles metadata
14616
- const layers = await discoverLayers(PMTILES_URL);
14646
+ const layers = await discoverLayers(this.PMTILES_URL);
14617
14647
  console.log('Discovered layers:', layers);
14618
- map.addSource('hardinessSource', {
14648
+ AddSource(map, this.SOURCE_ID, {
14619
14649
  type: 'vector',
14620
- url: PMTILES_URL,
14650
+ url: this.PMTILES_URL,
14621
14651
  });
14622
- map.addLayer({
14623
- id: 'hardiness-layer',
14624
- source: 'hardinessSource',
14625
- 'source-layer': 'hardiness2023',
14652
+ const added = AddLayer(map, {
14653
+ id: this.LAYER_ID,
14654
+ source: this.SOURCE_ID,
14655
+ 'source-layer': this.SOURCE_LAYER,
14626
14656
  type: 'fill',
14627
- paint: {
14628
- 'fill-color': [
14629
- 'case',
14630
- ['==', ['get', 'zone'], '1a'], '#1a237e',
14631
- ['==', ['get', 'zone'], '1b'], '#283593',
14632
- ['==', ['get', 'zone'], '2a'], '#3949ab',
14633
- ['==', ['get', 'zone'], '2b'], '#3f51b5',
14634
- ['==', ['get', 'zone'], '3a'], '#5c6bc0',
14635
- ['==', ['get', 'zone'], '3b'], '#7986cb',
14636
- ['==', ['get', 'zone'], '4a'], '#42a5f5',
14637
- ['==', ['get', 'zone'], '4b'], '#29b6f6',
14638
- ['==', ['get', 'zone'], '5a'], '#26c6da',
14639
- ['==', ['get', 'zone'], '5b'], '#26a69a',
14640
- ['==', ['get', 'zone'], '6a'], '#66bb6a',
14641
- ['==', ['get', 'zone'], '6b'], '#9ccc65',
14642
- ['==', ['get', 'zone'], '7a'], '#d4e157',
14643
- ['==', ['get', 'zone'], '7b'], '#ffee58',
14644
- ['==', ['get', 'zone'], '8a'], '#ffca28',
14645
- ['==', ['get', 'zone'], '8b'], '#ffa726',
14646
- ['==', ['get', 'zone'], '9a'], '#ff8a65',
14647
- ['==', ['get', 'zone'], '9b'], '#ff7043',
14648
- ['==', ['get', 'zone'], '10a'], '#f4511e',
14649
- ['==', ['get', 'zone'], '10b'], '#e53935',
14650
- ['==', ['get', 'zone'], '11a'], '#c62828',
14651
- ['==', ['get', 'zone'], '11b'], '#ad1457',
14652
- ['==', ['get', 'zone'], '12a'], '#8e24aa',
14653
- ['==', ['get', 'zone'], '12b'], '#7b1fa2',
14654
- ['==', ['get', 'zone'], '13a'], '#6a1b9a',
14655
- ['==', ['get', 'zone'], '13b'], '#4a148c',
14656
- '#cccccc' // default color for unknown zones
14657
- ],
14658
- 'fill-opacity': 0.7,
14659
- },
14660
- maxzoom: 14,
14661
14657
  }, StandardLayersMapper.POLYGONS_BACKGROUND);
14662
- // map.showTileBoundaries = true;
14663
- // map.addLayer(
14664
- // {
14665
- // id: 'hardiness-layer-line',
14666
- // source: 'hardinessSource',
14667
- // 'source-layer': 'hardiness2023',
14668
- // type: 'line',
14669
- // paint: {
14670
- // 'line-color': '#ffffff',
14671
- // 'line-width': 0.5,
14672
- // 'line-opacity': 0.8,
14673
- // },
14674
- // maxzoom: 14,
14675
- // },
14676
- // StandardLayersMapper.POLYGONS_BACKGROUND
14677
- // );
14678
- map.on('mousemove', 'hardiness-layer', (e) => {
14679
- this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
14680
- });
14681
- map.on('click', 'hardiness-layer', (e) => {
14682
- // Publish
14683
- this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
14684
- if (e.features && e.features.length > 0) {
14685
- const feature = e.features[0];
14686
- const coordinates = e.lngLat;
14687
- console.log('Feature properties:', feature.properties);
14688
- const name = feature.properties
14689
- ? feature.properties['zone']
14690
- : 'Unknown';
14691
- // Ensure that if the popup is already open, we don't create a new one
14692
- if (this.popup) {
14693
- this.popup.remove();
14658
+ this._update(this.settings());
14659
+ if (added) {
14660
+ map.on('mousemove', this.LAYER_ID, (e) => {
14661
+ this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
14662
+ });
14663
+ map.on('click', this.LAYER_ID, (e) => {
14664
+ // Publish
14665
+ this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
14666
+ if (e.features && e.features.length > 0) {
14667
+ const feature = e.features[0];
14668
+ const coordinates = e.lngLat;
14669
+ console.log('Feature properties:', feature.properties);
14670
+ const name = feature.properties
14671
+ ? feature.properties['zone']
14672
+ : 'Unknown';
14673
+ // Ensure that if the popup is already open, we don't create a new one
14674
+ if (this.popup) {
14675
+ this.popup.remove();
14676
+ }
14677
+ const fields = feature.properties
14678
+ ? Object.entries(feature.properties)
14679
+ .map(([key, value]) => `<strong>${key}:</strong> ${value}`)
14680
+ .join('<br/>')
14681
+ : '';
14682
+ this.currentFeatureID = feature?.properties?.['globalid'];
14683
+ this.popup = new Popup({ maxWidth: '400px' })
14684
+ .setLngLat(coordinates)
14685
+ .setHTML(`<strong>Hardiness:</strong> ${name}<hr /><br/>${fields}`)
14686
+ .addTo(map);
14694
14687
  }
14695
- const fields = feature.properties
14696
- ? Object.entries(feature.properties)
14697
- .map(([key, value]) => `<strong>${key}:</strong> ${value}`)
14698
- .join('<br/>')
14699
- : '';
14700
- this.currentFeatureID = feature?.properties?.['globalid'];
14701
- this.popup = new Popup({ maxWidth: '400px' })
14702
- .setLngLat(coordinates)
14703
- .setHTML(`<strong>Hardiness:</strong> ${name}<hr /><br/>${fields}`)
14704
- .addTo(map);
14705
- }
14706
- });
14688
+ });
14689
+ }
14690
+ }
14691
+ update(newSettings) {
14692
+ this.settings.set({ ...newSettings });
14693
+ }
14694
+ _update(settings) {
14695
+ if (!this.map) {
14696
+ return;
14697
+ }
14698
+ // Visiblitiy
14699
+ if (settings.visible) {
14700
+ this.map.setLayoutProperty(this.LAYER_ID, 'visibility', 'visible');
14701
+ }
14702
+ else {
14703
+ this.map.setLayoutProperty(this.LAYER_ID, 'visibility', 'none');
14704
+ }
14705
+ // Update paint properties
14706
+ this.map.setPaintProperty(this.LAYER_ID, 'fill-color', [
14707
+ 'case',
14708
+ ['==', ['get', 'zone'], '1a'], settings.zone1a,
14709
+ ['==', ['get', 'zone'], '1b'], settings.zone1b,
14710
+ ['==', ['get', 'zone'], '2a'], settings.zone2a,
14711
+ ['==', ['get', 'zone'], '2b'], settings.zone2b,
14712
+ ['==', ['get', 'zone'], '3a'], settings.zone3a,
14713
+ ['==', ['get', 'zone'], '3b'], settings.zone3b,
14714
+ ['==', ['get', 'zone'], '4a'], settings.zone4a,
14715
+ ['==', ['get', 'zone'], '4b'], settings.zone4b,
14716
+ ['==', ['get', 'zone'], '5a'], settings.zone5a,
14717
+ ['==', ['get', 'zone'], '5b'], settings.zone5b,
14718
+ ['==', ['get', 'zone'], '6a'], settings.zone6a,
14719
+ ['==', ['get', 'zone'], '6b'], settings.zone6b,
14720
+ ['==', ['get', 'zone'], '7a'], settings.zone7a,
14721
+ ['==', ['get', 'zone'], '7b'], settings.zone7b,
14722
+ ['==', ['get', 'zone'], '8a'], settings.zone8a,
14723
+ ['==', ['get', 'zone'], '8b'], settings.zone8b,
14724
+ ['==', ['get', 'zone'], '9a'], settings.zone9a,
14725
+ ['==', ['get', 'zone'], '9b'], settings.zone9b,
14726
+ ['==', ['get', 'zone'], '10a'], settings.zone10a,
14727
+ ['==', ['get', 'zone'], '10b'], settings.zone10b,
14728
+ ['==', ['get', 'zone'], '11a'], settings.zone11a,
14729
+ ['==', ['get', 'zone'], '11b'], settings.zone11b,
14730
+ ['==', ['get', 'zone'], '12a'], settings.zone12a,
14731
+ ['==', ['get', 'zone'], '12b'], settings.zone12b,
14732
+ ['==', ['get', 'zone'], '13a'], settings.zone13a,
14733
+ ['==', ['get', 'zone'], '13b'], settings.zone13b,
14734
+ settings.fillColor,
14735
+ ]);
14736
+ this.map.setPaintProperty(this.LAYER_ID, 'fill-opacity', settings.fillOpacity);
14737
+ // Set up the legend
14738
+ if (settings.visible) {
14739
+ this.legends = [
14740
+ {
14741
+ title: 'USDA Plant Hardiness Zones',
14742
+ items: [
14743
+ { value: settings.zone1a, label: 'Zone 1a' },
14744
+ { value: settings.zone1b, label: 'Zone 1b' },
14745
+ { value: settings.zone2a, label: 'Zone 2a' },
14746
+ { value: settings.zone2b, label: 'Zone 2b' },
14747
+ { value: settings.zone3a, label: 'Zone 3a' },
14748
+ { value: settings.zone3b, label: 'Zone 3b' },
14749
+ { value: settings.zone4a, label: 'Zone 4a' },
14750
+ { value: settings.zone4b, label: 'Zone 4b' },
14751
+ { value: settings.zone5a, label: 'Zone 5a' },
14752
+ { value: settings.zone5b, label: 'Zone 5b' },
14753
+ { value: settings.zone6a, label: 'Zone 6a' },
14754
+ { value: settings.zone6b, label: 'Zone 6b' },
14755
+ { value: settings.zone7a, label: 'Zone 7a' },
14756
+ { value: settings.zone7b, label: 'Zone 7b' },
14757
+ { value: settings.zone8a, label: 'Zone 8a' },
14758
+ { value: settings.zone8b, label: 'Zone 8b' },
14759
+ { value: settings.zone9a, label: 'Zone 9a' },
14760
+ { value: settings.zone9b, label: 'Zone 9b' },
14761
+ { value: settings.zone10a, label: 'Zone 10a' },
14762
+ { value: settings.zone10b, label: 'Zone 10b' },
14763
+ { value: settings.zone11a, label: 'Zone 11a' },
14764
+ { value: settings.zone11b, label: 'Zone 11b' },
14765
+ { value: settings.zone12a, label: 'Zone 12a' },
14766
+ { value: settings.zone12b, label: 'Zone 12b' },
14767
+ { value: settings.zone13a, label: 'Zone 13a' },
14768
+ { value: settings.zone13b, label: 'Zone 13b' },
14769
+ ],
14770
+ },
14771
+ ];
14772
+ }
14773
+ else {
14774
+ this.legends = undefined;
14775
+ }
14776
+ }
14777
+ async onReady(map, svc) {
14778
+ this.map = map;
14779
+ this.create();
14707
14780
  }
14708
14781
  reset() { }
14709
- clear() { }
14782
+ clear() {
14783
+ RemoveLayer(this.map, this.LAYER_ID);
14784
+ RemoveSource(this.map, this.SOURCE_ID);
14785
+ }
14710
14786
  legends;
14711
14787
  count = 0;
14712
14788
  total = 0;
14713
14789
  map;
14714
14790
  popup = null;
14715
14791
  }
14792
+ class HardinessSettings extends PolygonLayerSettings {
14793
+ zone1a = '#1a237e';
14794
+ zone1b = '#283593';
14795
+ zone2a = '#3949ab';
14796
+ zone2b = '#3f51b5';
14797
+ zone3a = '#5c6bc0';
14798
+ zone3b = '#7986cb';
14799
+ zone4a = '#42a5f5';
14800
+ zone4b = '#29b6f6';
14801
+ zone5a = '#26c6da';
14802
+ zone5b = '#26a69a';
14803
+ zone6a = '#66bb6a';
14804
+ zone6b = '#9ccc65';
14805
+ zone7a = '#d4e157';
14806
+ zone7b = '#ffee58';
14807
+ zone8a = '#ffca28';
14808
+ zone8b = '#ffa726';
14809
+ zone9a = '#ff8a65';
14810
+ zone9b = '#ff7043';
14811
+ zone10a = '#f4511e';
14812
+ zone10b = '#e53935';
14813
+ zone11a = '#c62828';
14814
+ zone11b = '#ad1457';
14815
+ zone12a = '#8e24aa';
14816
+ zone12b = '#7b1fa2';
14817
+ zone13a = '#6a1b9a';
14818
+ zone13b = '#4a148c';
14819
+ fillColor = '#cccccc'; // default color for unknown zones
14820
+ fillOpacity = 0.7;
14821
+ borderOpacity = 0;
14822
+ }
14716
14823
 
14717
14824
  class VectorTileServerMapper {
14718
14825
  src;
@@ -14824,43 +14931,73 @@ class VectorTileServerMapper {
14824
14931
  // }
14825
14932
 
14826
14933
  class WatershedMapper {
14934
+ FILL_LAYER_ID = 'watershed-layer';
14935
+ LINE_LAYER_ID = 'watershed-layer-line';
14936
+ SOURCE_ID = 'watershedSource';
14937
+ SOURCE_LAYER = 'watershedhu6';
14938
+ settings = signal(new WatershedSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
14827
14939
  current = null;
14828
14940
  currentFeatureID = undefined;
14829
14941
  over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
14830
- async onReady(map, svc) {
14831
- this.map = map;
14942
+ constructor() {
14943
+ const _ = effect(() => {
14944
+ const settings = this.settings();
14945
+ this._update(settings);
14946
+ }, ...(ngDevMode ? [{ debugName: "_" }] : []));
14947
+ }
14948
+ update(settings) {
14949
+ this.settings.set({ ...settings });
14950
+ }
14951
+ _update(settings) {
14952
+ if (!this.map) {
14953
+ return;
14954
+ }
14955
+ const map = this.map;
14956
+ if (settings.visible) {
14957
+ map.setLayoutProperty(this.FILL_LAYER_ID, 'visibility', 'visible');
14958
+ map.setLayoutProperty(this.LINE_LAYER_ID, 'visibility', 'visible');
14959
+ }
14960
+ else {
14961
+ map.setLayoutProperty(this.FILL_LAYER_ID, 'visibility', 'none');
14962
+ map.setLayoutProperty(this.LINE_LAYER_ID, 'visibility', 'none');
14963
+ }
14964
+ map.setPaintProperty(this.FILL_LAYER_ID, 'fill-color', settings.fillColor);
14965
+ map.setPaintProperty(this.FILL_LAYER_ID, 'fill-opacity', settings.fillOpacity);
14966
+ map.setPaintProperty(this.LINE_LAYER_ID, 'line-color', settings.borderColor);
14967
+ map.setPaintProperty(this.LINE_LAYER_ID, 'line-width', settings.borderWidth);
14968
+ map.setPaintProperty(this.LINE_LAYER_ID, 'line-opacity', settings.borderOpacity);
14969
+ }
14970
+ create() {
14971
+ if (!this.map) {
14972
+ return;
14973
+ }
14974
+ const map = this.map;
14832
14975
  const PMTILES_URL = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/watershedhu6.pmtiles';
14833
- map.addSource('pmTileSourceName', {
14976
+ AddSource(map, this.SOURCE_ID, {
14834
14977
  type: 'vector',
14835
14978
  url: PMTILES_URL,
14836
14979
  });
14837
- map.addLayer({
14838
- id: 'watershed-layer',
14839
- source: 'pmTileSourceName',
14840
- 'source-layer': 'watershedhu6',
14980
+ const addedFill = AddLayer(map, {
14981
+ id: this.FILL_LAYER_ID,
14982
+ source: this.SOURCE_ID,
14983
+ "source-layer": this.SOURCE_LAYER,
14841
14984
  type: 'fill',
14842
- paint: {
14843
- 'fill-color': 'steelblue',
14844
- 'fill-opacity': 0.1,
14845
- },
14846
- maxzoom: 14,
14847
14985
  }, StandardLayersMapper.POLYGONS_BACKGROUND);
14848
14986
  // map.showTileBoundaries = true;
14849
- map.addLayer({
14850
- id: 'watershed-layer-line',
14851
- source: 'pmTileSourceName',
14852
- 'source-layer': 'watershedhu6',
14987
+ AddLayer(map, {
14988
+ id: this.LINE_LAYER_ID,
14989
+ source: this.SOURCE_ID,
14990
+ "source-layer": this.SOURCE_LAYER,
14853
14991
  type: 'line',
14854
- paint: {
14855
- 'line-color': 'steelblue',
14856
- 'line-width': 1,
14857
- },
14858
- maxzoom: 14,
14859
14992
  }, StandardLayersMapper.POLYGONS_BACKGROUND);
14860
- map.on('mousemove', 'watershed-layer', (e) => {
14993
+ this._update(this.settings());
14994
+ if (!addedFill) {
14995
+ return;
14996
+ }
14997
+ map.on('mousemove', this.FILL_LAYER_ID, (e) => {
14861
14998
  this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
14862
14999
  });
14863
- map.on('click', 'watershed-layer', (e) => {
15000
+ map.on('click', this.FILL_LAYER_ID, (e) => {
14864
15001
  // Publish
14865
15002
  this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
14866
15003
  if (e.features && e.features.length > 0) {
@@ -14887,14 +15024,32 @@ class WatershedMapper {
14887
15024
  }
14888
15025
  });
14889
15026
  }
15027
+ async onReady(map, svc) {
15028
+ this.map = map;
15029
+ this.create();
15030
+ }
14890
15031
  reset() { }
14891
- clear() { }
15032
+ clear() {
15033
+ if (this.map) {
15034
+ this.map.removeLayer(this.FILL_LAYER_ID);
15035
+ this.map.removeLayer(this.LINE_LAYER_ID);
15036
+ this.map.removeSource(this.SOURCE_ID);
15037
+ }
15038
+ }
14892
15039
  legends;
14893
15040
  count = 0;
14894
15041
  total = 0;
14895
15042
  map;
14896
15043
  popup = null;
14897
15044
  }
15045
+ class WatershedSettings {
15046
+ visible = true;
15047
+ fillColor = '#0000ff';
15048
+ fillOpacity = 0.1;
15049
+ borderColor = '#01018bff';
15050
+ borderWidth = 1;
15051
+ borderOpacity = 1.0;
15052
+ }
14898
15053
 
14899
15054
  class HttpBoundaryLoader {
14900
15055
  static NewCustom(http, path) {
@@ -14998,5 +15153,5 @@ class HttpBoundaryLoader {
14998
15153
  * Generated bundle index. Do not edit.
14999
15154
  */
15000
15155
 
15001
- export { AddLayer, AddSource, AreaMapperMapper, BackgroundMaskMapper, BaseMapLight, BasemapSelect, BasemapSelectMenu, CensusTractMapper, DrawingMapper, HardinessMapper, HttpBoundaryLoader, MapAreaSelectComponent, MapComponent, MapSelectionService, MapService, MapStyles, MapboxMapperGroup, NoOpMapper, RemoveLayer, RemoveSource, SaveMap, SelectMode, StandardLayersMapper, Styles, VectorTileServerMapper, WatershedMapper, discoverLayers, isGeoloader, isMultiPolygon, isNumber2DArray, isNumber3DArray, isPolygon, mapboxLoadImages, mapboxloadImage, sampleTilesForLayers, simpleClone, toMultiPolygon, trySync };
15156
+ export { AddLayer, AddSource, AreaMapperMapper, BackgroundMaskMapper, BaseMapLight, BasemapSelect, BasemapSelectMenu, CensusTractMapper, DrawingMapper, HardinessMapper, HardinessSettings, HttpBoundaryLoader, MapAreaSelectComponent, MapComponent, MapSelectionService, MapService, MapStyles, MapboxMapperGroup, NoOpMapper, RemoveLayer, RemoveSource, SaveMap, SelectMode, StandardLayersMapper, Styles, VectorTileServerMapper, WatershedMapper, WatershedSettings, discoverLayers, isGeoloader, isMultiPolygon, isNumber2DArray, isNumber3DArray, isPolygon, mapboxLoadImages, mapboxloadImage, sampleTilesForLayers, simpleClone, toMultiPolygon, trySync };
15002
15157
  //# sourceMappingURL=foodmarketmaker-mapag.mjs.map