@foodmarketmaker/mapag 0.0.11 → 0.0.13

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.
@@ -14973,11 +14973,13 @@ class WatershedMapper {
14973
14973
  map.setPaintProperty(this.LINE_LAYER_ID, 'line-color', settings.borderColor);
14974
14974
  map.setPaintProperty(this.LINE_LAYER_ID, 'line-width', settings.borderWidth);
14975
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);
14976
+ const watershedLabelVisible = settings.visible && settings.labelsVisible;
14977
+ map.setLayoutProperty(this.LABEL_LAYER_ID, 'visibility', watershedLabelVisible ? 'visible' : 'none');
14978
14978
  map.setPaintProperty(this.LABEL_LAYER_ID, 'text-color', settings.labelsColor);
14979
14979
  map.setPaintProperty(this.LABEL_LAYER_ID, 'text-halo-color', settings.labelsHaloColor);
14980
14980
  map.setPaintProperty(this.LABEL_LAYER_ID, 'text-halo-width', settings.labelsHaloWidth);
14981
+ map.setPaintProperty(this.LABEL_LAYER_ID, 'text-opacity', settings.labelsOpacity);
14982
+ map.setLayoutProperty(this.LABEL_LAYER_ID, 'text-size', settings.labelsSize);
14981
14983
  }
14982
14984
  create() {
14983
14985
  if (!this.map) {
@@ -15038,12 +15040,46 @@ class WatershedMapper {
15038
15040
  type: 'symbol',
15039
15041
  layout: {
15040
15042
  'text-field': ['get', 'name'],
15043
+ 'text-size': this.settings().labelsSize,
15044
+ 'text-allow-overlap': true,
15045
+ },
15046
+ paint: {
15047
+ 'text-color': this.settings().labelsColor,
15048
+ 'text-halo-color': this.settings().labelsHaloColor,
15049
+ 'text-halo-width': this.settings().labelsHaloWidth,
15050
+ // 'text-size': this.settings().labelsSize,
15041
15051
  },
15042
15052
  }, StandardLayersMapper.POLYGONS_BACKGROUND);
15043
15053
  this._update(this.settings());
15044
15054
  if (!addedFill) {
15045
15055
  return;
15046
15056
  }
15057
+ map.on('zoomend', () => {
15058
+ if (!this.settings().visible) {
15059
+ return;
15060
+ }
15061
+ const zoom = map.getZoom();
15062
+ if (this.settings().autoSelectLayer) {
15063
+ if (zoom >= 0 && zoom < 5 && this.currentHU !== 'HUC2') {
15064
+ this.update({ hydrologicUnit: 'HUC2' });
15065
+ }
15066
+ else if (zoom >= 5 && zoom < 7 && this.currentHU !== 'HUC4') {
15067
+ this.update({ hydrologicUnit: 'HUC4' });
15068
+ }
15069
+ else if (zoom >= 7 && zoom < 9 && this.currentHU !== 'HUC6') {
15070
+ this.update({ hydrologicUnit: 'HUC6' });
15071
+ }
15072
+ else if (zoom >= 9 && zoom < 11 && this.currentHU !== 'HUC8') {
15073
+ this.update({ hydrologicUnit: 'HUC8' });
15074
+ }
15075
+ else if (zoom >= 11 && zoom < 13 && this.currentHU !== 'HUC10') {
15076
+ this.update({ hydrologicUnit: 'HUC10' });
15077
+ }
15078
+ else if (zoom >= 13 && this.currentHU !== 'HUC12') {
15079
+ this.update({ hydrologicUnit: 'HUC12' });
15080
+ }
15081
+ }
15082
+ });
15047
15083
  map.on('mousemove', this.FILL_LAYER_ID, (e) => {
15048
15084
  this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
15049
15085
  });
@@ -15102,10 +15138,12 @@ class WatershedSettings {
15102
15138
  borderWidth = 1;
15103
15139
  borderOpacity = 1.0;
15104
15140
  labelsVisible = true;
15105
- labelsSize = 12;
15141
+ labelsSize = 10;
15106
15142
  labelsColor = '#000000';
15107
15143
  labelsHaloColor = '#ffffff';
15108
15144
  labelsHaloWidth = 1;
15145
+ labelsOpacity = 1.0;
15146
+ autoSelectLayer = false;
15109
15147
  }
15110
15148
 
15111
15149
  class HttpBoundaryLoader {