@foodmarketmaker/mapag 0.0.21 → 0.0.22
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.
|
@@ -14625,6 +14625,168 @@ class CensusTractMapper {
|
|
|
14625
14625
|
};
|
|
14626
14626
|
}
|
|
14627
14627
|
|
|
14628
|
+
class CropSequenceMapper {
|
|
14629
|
+
static PMTILES = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/NationalCSB_2017_2024_rev23.pmtiles';
|
|
14630
|
+
FILL_LAYER_ID = 'cropsequence-layer';
|
|
14631
|
+
LINE_LAYER_ID = 'cropsequence-layer-line';
|
|
14632
|
+
LABEL_LAYER_ID = 'cropsequence-layer-label';
|
|
14633
|
+
SOURCE_ID = 'cropsequence-source';
|
|
14634
|
+
SOURCE_LAYER = 'NationalCSB_2017_2024_rev23';
|
|
14635
|
+
settings = signal(new CropSequenceSettings(), ...(ngDevMode ? [{ debugName: "settings" }] : []));
|
|
14636
|
+
current = null;
|
|
14637
|
+
currentFeatureID = undefined;
|
|
14638
|
+
over = signal(null, ...(ngDevMode ? [{ debugName: "over" }] : []));
|
|
14639
|
+
constructor(settings) {
|
|
14640
|
+
if (settings) {
|
|
14641
|
+
this.settings.set({
|
|
14642
|
+
...this.settings(),
|
|
14643
|
+
...settings
|
|
14644
|
+
});
|
|
14645
|
+
}
|
|
14646
|
+
const _ = effect(() => {
|
|
14647
|
+
const settings = this.settings();
|
|
14648
|
+
this._update(settings);
|
|
14649
|
+
}, ...(ngDevMode ? [{ debugName: "_" }] : []));
|
|
14650
|
+
}
|
|
14651
|
+
update(settings) {
|
|
14652
|
+
this.settings.set({ ...this.settings(), ...settings });
|
|
14653
|
+
}
|
|
14654
|
+
_update(settings) {
|
|
14655
|
+
if (!this.map) {
|
|
14656
|
+
return;
|
|
14657
|
+
}
|
|
14658
|
+
const map = this.map;
|
|
14659
|
+
if (settings.visible) {
|
|
14660
|
+
map.setLayoutProperty(this.FILL_LAYER_ID, 'visibility', 'visible');
|
|
14661
|
+
map.setLayoutProperty(this.LINE_LAYER_ID, 'visibility', 'visible');
|
|
14662
|
+
}
|
|
14663
|
+
else {
|
|
14664
|
+
map.setLayoutProperty(this.FILL_LAYER_ID, 'visibility', 'none');
|
|
14665
|
+
map.setLayoutProperty(this.LINE_LAYER_ID, 'visibility', 'none');
|
|
14666
|
+
}
|
|
14667
|
+
map.setPaintProperty(this.FILL_LAYER_ID, 'fill-color', settings.fillColor);
|
|
14668
|
+
map.setPaintProperty(this.FILL_LAYER_ID, 'fill-opacity', settings.fillOpacity);
|
|
14669
|
+
map.setPaintProperty(this.LINE_LAYER_ID, 'line-color', settings.borderColor);
|
|
14670
|
+
map.setPaintProperty(this.LINE_LAYER_ID, 'line-width', settings.borderWidth);
|
|
14671
|
+
map.setPaintProperty(this.LINE_LAYER_ID, 'line-opacity', settings.borderOpacity);
|
|
14672
|
+
const labelsVisible = settings.visible && settings.labelsVisible;
|
|
14673
|
+
map.setLayoutProperty(this.LABEL_LAYER_ID, 'visibility', labelsVisible ? 'visible' : 'none');
|
|
14674
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-color', settings.labelsColor);
|
|
14675
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-halo-color', settings.labelsHaloColor);
|
|
14676
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-halo-width', settings.labelsHaloWidth);
|
|
14677
|
+
map.setPaintProperty(this.LABEL_LAYER_ID, 'text-opacity', settings.labelsOpacity);
|
|
14678
|
+
map.setLayoutProperty(this.LABEL_LAYER_ID, 'text-size', settings.labelsSize);
|
|
14679
|
+
map.setLayoutProperty(this.LABEL_LAYER_ID, 'text-allow-overlap', settings.labelOverlap);
|
|
14680
|
+
}
|
|
14681
|
+
create() {
|
|
14682
|
+
if (!this.map) {
|
|
14683
|
+
return;
|
|
14684
|
+
}
|
|
14685
|
+
const map = this.map;
|
|
14686
|
+
let PMTILES_URL = CropSequenceMapper.PMTILES;
|
|
14687
|
+
AddSource(map, this.SOURCE_ID, {
|
|
14688
|
+
type: 'vector',
|
|
14689
|
+
url: PMTILES_URL,
|
|
14690
|
+
});
|
|
14691
|
+
const addedFill = AddLayer(map, {
|
|
14692
|
+
id: this.FILL_LAYER_ID,
|
|
14693
|
+
source: this.SOURCE_ID,
|
|
14694
|
+
"source-layer": this.SOURCE_LAYER,
|
|
14695
|
+
type: 'fill',
|
|
14696
|
+
}, StandardLayersMapper.POLYGONS_BACKGROUND);
|
|
14697
|
+
map.showTileBoundaries = true;
|
|
14698
|
+
AddLayer(map, {
|
|
14699
|
+
id: this.LINE_LAYER_ID,
|
|
14700
|
+
source: this.SOURCE_ID,
|
|
14701
|
+
"source-layer": this.SOURCE_LAYER,
|
|
14702
|
+
type: 'line',
|
|
14703
|
+
}, StandardLayersMapper.POLYGONS_BACKGROUND);
|
|
14704
|
+
AddLayer(map, {
|
|
14705
|
+
id: this.LABEL_LAYER_ID,
|
|
14706
|
+
source: this.SOURCE_ID,
|
|
14707
|
+
"source-layer": this.SOURCE_LAYER,
|
|
14708
|
+
type: 'symbol',
|
|
14709
|
+
layout: {
|
|
14710
|
+
'text-field': ['get', 'name'],
|
|
14711
|
+
'text-font': ['Open Sans Regular'],
|
|
14712
|
+
'text-size': this.settings().labelsSize,
|
|
14713
|
+
'text-allow-overlap': this.settings().labelOverlap,
|
|
14714
|
+
},
|
|
14715
|
+
paint: {
|
|
14716
|
+
'text-color': this.settings().labelsColor,
|
|
14717
|
+
'text-halo-color': this.settings().labelsHaloColor,
|
|
14718
|
+
'text-halo-width': this.settings().labelsHaloWidth,
|
|
14719
|
+
},
|
|
14720
|
+
}, StandardLayersMapper.POLYGONS_BACKGROUND);
|
|
14721
|
+
this._update(this.settings());
|
|
14722
|
+
if (!addedFill) {
|
|
14723
|
+
return;
|
|
14724
|
+
}
|
|
14725
|
+
map.on('mousemove', this.FILL_LAYER_ID, (e) => {
|
|
14726
|
+
this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
|
|
14727
|
+
});
|
|
14728
|
+
map.on('click', this.FILL_LAYER_ID, (e) => {
|
|
14729
|
+
// Publish
|
|
14730
|
+
this.over.set(e.features && e.features.length > 0 ? e.features[0] : null);
|
|
14731
|
+
if (e.features && e.features.length > 0) {
|
|
14732
|
+
const feature = e.features[0];
|
|
14733
|
+
const coordinates = e.lngLat;
|
|
14734
|
+
console.log('Feature properties:', feature.properties);
|
|
14735
|
+
const name = feature.properties
|
|
14736
|
+
? feature.properties['name']
|
|
14737
|
+
: 'Unknown';
|
|
14738
|
+
// Ensure that if the popup is already open, we don't create a new one
|
|
14739
|
+
if (this.popup) {
|
|
14740
|
+
this.popup.remove();
|
|
14741
|
+
}
|
|
14742
|
+
const fields = feature.properties
|
|
14743
|
+
? Object.entries(feature.properties)
|
|
14744
|
+
.map(([key, value]) => `<strong>${key}:</strong> ${value}`)
|
|
14745
|
+
.join('<br/>')
|
|
14746
|
+
: '';
|
|
14747
|
+
this.currentFeatureID = feature?.properties?.['globalid'];
|
|
14748
|
+
this.popup = new Popup({ maxWidth: '400px' })
|
|
14749
|
+
.setLngLat(coordinates)
|
|
14750
|
+
.setHTML(`<strong>Watershed:</strong> ${name}<hr /><br/>${fields}`)
|
|
14751
|
+
.addTo(map);
|
|
14752
|
+
}
|
|
14753
|
+
});
|
|
14754
|
+
}
|
|
14755
|
+
async onReady(map, svc) {
|
|
14756
|
+
this.map = map;
|
|
14757
|
+
this.create();
|
|
14758
|
+
}
|
|
14759
|
+
reset() { }
|
|
14760
|
+
clear() {
|
|
14761
|
+
if (this.map) {
|
|
14762
|
+
this.map.removeLayer(this.FILL_LAYER_ID);
|
|
14763
|
+
this.map.removeLayer(this.LINE_LAYER_ID);
|
|
14764
|
+
this.map.removeLayer(this.LABEL_LAYER_ID);
|
|
14765
|
+
this.map.removeSource(this.SOURCE_ID);
|
|
14766
|
+
}
|
|
14767
|
+
}
|
|
14768
|
+
legends;
|
|
14769
|
+
count = 0;
|
|
14770
|
+
total = 0;
|
|
14771
|
+
map;
|
|
14772
|
+
popup = null;
|
|
14773
|
+
}
|
|
14774
|
+
class CropSequenceSettings {
|
|
14775
|
+
visible = true;
|
|
14776
|
+
fillColor = '#0000ff';
|
|
14777
|
+
fillOpacity = 0.1;
|
|
14778
|
+
borderColor = '#01018b';
|
|
14779
|
+
borderWidth = 1;
|
|
14780
|
+
borderOpacity = 1.0;
|
|
14781
|
+
labelsVisible = true;
|
|
14782
|
+
labelsSize = 10;
|
|
14783
|
+
labelsColor = '#000000';
|
|
14784
|
+
labelsHaloColor = '#ffffff';
|
|
14785
|
+
labelsHaloWidth = 1;
|
|
14786
|
+
labelsOpacity = 1.0;
|
|
14787
|
+
labelOverlap = false;
|
|
14788
|
+
}
|
|
14789
|
+
|
|
14628
14790
|
class CroplandDataLayerMapper {
|
|
14629
14791
|
static PMTILES = 'pmtiles://https://foodmarketmaker-upload-data.s3.us-west-2.amazonaws.com/tiles/cdl_2024_30m.pmtiles';
|
|
14630
14792
|
LAYER_ID = 'cropland-data-layer';
|
|
@@ -16573,5 +16735,5 @@ class HttpBoundaryLoader {
|
|
|
16573
16735
|
* Generated bundle index. Do not edit.
|
|
16574
16736
|
*/
|
|
16575
16737
|
|
|
16576
|
-
export { AddLayer, AddSource, AreaMapperMapper, BackgroundMaskMapper, BackgroundMaskSettings, BaseMapLight, BasemapSelect, BasemapSelectMenu, CensusTractMapper, Codes, CroplandDataLayerMapper, CroplandDataLayerSettings, CroplandLegend, DEFAULT_GLYPHS, DrawingMapper, EsriMapper, EsriSettings, HardinessMapper, HardinessSettings, HttpBoundaryLoader, MapAreaSelectComponent, MapComponent, MapSelectionService, MapService, MapStyles, MapboxMapperGroup, NAASMapper, NAASSettings, NaicsMapper, NaicsMapperSettings, NoOpMapper, RemoveLayer, RemoveSource, SaveMap, SelectMode, SimpleMapper, StandardLayersMapper, Styles, VectorTileServerMapper, WatershedMapper, WatershedSettings, discoverLayers, isGeoloader, isMultiPolygon, isNumber2DArray, isNumber3DArray, isPolygon, mapboxLoadImages, mapboxloadImage, pmtilesPixelInfo, sampleTilesForLayers, simpleClone, toMultiPolygon, trySync };
|
|
16738
|
+
export { AddLayer, AddSource, AreaMapperMapper, BackgroundMaskMapper, BackgroundMaskSettings, BaseMapLight, BasemapSelect, BasemapSelectMenu, CensusTractMapper, Codes, CropSequenceMapper, CropSequenceSettings, CroplandDataLayerMapper, CroplandDataLayerSettings, CroplandLegend, DEFAULT_GLYPHS, DrawingMapper, EsriMapper, EsriSettings, HardinessMapper, HardinessSettings, HttpBoundaryLoader, MapAreaSelectComponent, MapComponent, MapSelectionService, MapService, MapStyles, MapboxMapperGroup, NAASMapper, NAASSettings, NaicsMapper, NaicsMapperSettings, NoOpMapper, RemoveLayer, RemoveSource, SaveMap, SelectMode, SimpleMapper, StandardLayersMapper, Styles, VectorTileServerMapper, WatershedMapper, WatershedSettings, discoverLayers, isGeoloader, isMultiPolygon, isNumber2DArray, isNumber3DArray, isPolygon, mapboxLoadImages, mapboxloadImage, pmtilesPixelInfo, sampleTilesForLayers, simpleClone, toMultiPolygon, trySync };
|
|
16577
16739
|
//# sourceMappingURL=foodmarketmaker-mapag.mjs.map
|