From 714bdb54561a86a3c6000ad3c03fffa1522c6e5a Mon Sep 17 00:00:00 2001 From: Adam Doe <17502761+adamdoe@users.noreply.github.com> Date: Wed, 8 Jan 2025 14:28:11 -0800 Subject: [PATCH] [dev-10217b] image updates --- packages/core/components/MediaControls.jsx | 92 ++- .../map/examples/default-usa-regions.json | 762 ++++++++++++++++-- packages/map/index.html | 9 +- .../components/Legend/components/Legend.tsx | 2 +- .../UsaMap/components/TerritoriesSection.tsx | 4 +- 5 files changed, 760 insertions(+), 109 deletions(-) diff --git a/packages/core/components/MediaControls.jsx b/packages/core/components/MediaControls.jsx index 6928fa488..0843c5d93 100644 --- a/packages/core/components/MediaControls.jsx +++ b/packages/core/components/MediaControls.jsx @@ -25,26 +25,64 @@ function saveImage(element) { } const saveImageAs = (uri, filename) => { - const ie = navigator.userAgent.match(/MSIE\s([\d.]+)/) - const ie11 = navigator.userAgent.match(/Trident\/7.0/) && navigator.userAgent.match(/rv:11/) - const ieEdge = navigator.userAgent.match(/Edge/g) - const ieVer = ie ? ie[1] : ie11 ? 11 : ieEdge ? 12 : -1 - - if (ieVer > -1) { - const fileAsBlob = new Blob([uri], { - type: 'image/png' - }) - window.navigator.msSaveBlob(fileAsBlob, filename) - } else { - const link = document.createElement('a') - if (typeof link.download === 'string') { - link.href = uri - link.download = filename - link.onclick = e => document.body.removeChild(e.target) - document.body.appendChild(link) - link.click() + // Target resolution in inches + const targetWidthInInches = 13.33 // 13.33 inches for 4000 pixels at 300 DPI + const targetHeightInInches = 7.5 // 7.5 inches for 2250 pixels at 300 DPI + const dpi = 300 + + // Calculate target resolution in pixels + const targetWidth = targetWidthInInches * dpi + const targetHeight = targetHeightInInches * dpi + + // Check for the device pixel ratio to handle different screen densities + const dpr = window.devicePixelRatio || 1 // Default to 1 if DPR is not available + + // Create an image to load the URI + const img = new Image() + img.src = uri + + img.onload = () => { + // Create a canvas to adjust the image size + const canvas = document.createElement('canvas') + const ctx = canvas.getContext('2d') + + // Set canvas size to the target resolution, scaled by device pixel ratio + canvas.width = targetWidth * dpr + canvas.height = targetHeight * dpr + + // Scale the context to handle high DPI + ctx.scale(dpr, dpr) + + // ctx.filter = 'grayscale(100%)' + + // Draw the image on the canvas, scaling it to fit the target resolution + ctx.drawImage(img, 0, 0, targetWidth, targetHeight) + + // Convert canvas to data URL with high quality + const finalUri = canvas.toDataURL('image/jpeg', 1) // Highest quality + + // Saving logic for IE and modern browsers + const ie = navigator.userAgent.match(/MSIE\s([\d.]+)/) + const ie11 = navigator.userAgent.match(/Trident\/7.0/) && navigator.userAgent.match(/rv:11/) + const ieEdge = navigator.userAgent.match(/Edge/g) + const ieVer = ie ? ie[1] : ie11 ? 11 : ieEdge ? 12 : -1 + + if (ieVer > -1) { + // IE-specific file saving logic + const fileAsBlob = new Blob([finalUri], { type: 'image/jpeg' }) + window.navigator.msSaveBlob(fileAsBlob, filename) } else { - window.open(uri) + // Modern browsers + const link = document.createElement('a') + if (typeof link.download === 'string') { + link.href = finalUri + link.download = filename + link.onclick = e => document.body.removeChild(e.target) + document.body.appendChild(link) + link.click() + } else { + window.open(finalUri) + } } } } @@ -52,6 +90,13 @@ const saveImageAs = (uri, filename) => { const generateMedia = (state, type, elementToCapture) => { // Identify Selector const baseSvg = document.querySelector(`[data-download-id=${elementToCapture}]`) + const aside = document.querySelector('aside') // Assuming aside contains the legend + + // Temporarily change the legend (aside) border color to black + const originalBorder = aside ? aside.style.border : null + if (aside) { + aside.style.border = '1px solid var(--cool-gray-90)' + } // Handles different state title locations between components // Apparently some packages use state.title where others use state.general.title @@ -98,7 +143,14 @@ const generateMedia = (state, type, elementToCapture) => { if (state.visualizationType === 'Scatter Plot') { saveImage(baseSvg) } else { - saveImageAs(canvas.toDataURL(), filename + '.png') + saveImageAs(canvas.toDataURL(), filename + '.jpeg') + + // Reset the aside border color after a delay + setTimeout(() => { + if (aside && originalBorder !== null) { + aside.style.border = originalBorder + } + }, 1500) // Wait for half a second before resetting } }) return diff --git a/packages/map/examples/default-usa-regions.json b/packages/map/examples/default-usa-regions.json index 8a790885b..fa8fa93e0 100644 --- a/packages/map/examples/default-usa-regions.json +++ b/packages/map/examples/default-usa-regions.json @@ -1,10 +1,7 @@ { - "annotations": [], "general": { - "geoType": "us-region", + "geoType": "us", "type": "data", - "noStateFoundMessage": "Map Unavailable", - "annotationDropdownText": "Annotations", "geoBorderColor": "darkGray", "headerColor": "theme-blue", "title": "", @@ -31,13 +28,17 @@ "fipsCode": "01", "stateName": "Alabama" }, - "expandDataTable": false + "expandDataTable": false, + "navigationTarget": "_self", + "noStateFoundMessage": "Map Unavailable", + "annotationDropdownText": "Annotations", + "showDownloadImgButton": true }, "type": "map", "color": "pinkpurple", "columns": { "geo": { - "name": "State", + "name": "STATE", "label": "Location", "tooltip": false, "dataTable": true @@ -47,7 +48,7 @@ "tooltip": true, "prefix": "", "suffix": "", - "name": "Current Week Positivity", + "name": "Rate", "label": "", "roundToPlace": 0 }, @@ -73,7 +74,7 @@ "type": "equalnumber", "numberOfItems": 3, "position": "side", - "title": "", + "title": "Legend", "style": "circles", "subStyle": "linear blocks", "tickRotation": "", @@ -90,11 +91,11 @@ "caption": "", "showDownloadUrl": false, "showDataTableLink": true, - "showDownloadLinkBelow": true, "showFullGeoNameInCSV": false, "forceDisplay": true, "download": true, - "indexLabel": "" + "indexLabel": "", + "showDownloadLinkBelow": true }, "tooltips": { "appearanceType": "hover", @@ -145,124 +146,725 @@ ] }, "filterBehavior": "Filter Change", + "filterIntro": "", "datasets": {}, - "isResponsiveTicks": false, - "barThickness": "0.37", - "xAxis": { - "type": "categorical", - "size": 75, - "maxTickRotation": 45, - "labelOffset": 0 - }, "data": [ { - "Current Week Positivity": "20", - "State": "REGION 1", - "Change": "0.2" + "STATE": "Overall", + "Rate": "55", + "Location": "Vehicle", + "URL": "https://www.cdc.gov" + }, + { + "STATE": "Alabama", + "Rate": 130, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Alaska", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "American Samoa", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Arizona", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Arkansas", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "California", + "Rate": 30, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Colorado", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Connecticut", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Deleware", + "Rate": "57", + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "DC", + "Rate": 60, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Florida", + "Rate": 30, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Georgia", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Guam", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Hawaii", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Idaho", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Illinois", + "Rate": 30, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Indiana", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Iowa", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Kansas", + "Rate": 57, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Kentucky", + "Rate": 60, + "Location": "NA", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Louisiana", + "Rate": 30, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Maine", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Marshall Islands", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Maryland", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Massachusetts", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Michigan", + "Rate": 12, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Micronesia", + "Rate": 65, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Minnesota", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Mississippi", + "Rate": 57, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Montana", + "Rate": 60, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Montana", + "Rate": 30, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Nebraska", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Nevada", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New Hampshire", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New Jersey", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New Mexico", + "Rate": 12, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New York", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "North Carolina", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "North Dakota", + "Rate": 57, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Northern Mariana Islands", + "Rate": "60", + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Ohio", + "Rate": 88, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Oklahoma", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Oregon", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Palau", + "Rate": 15, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Pennsylvania", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Puerto Rico", + "Rate": 30, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Rhode Island", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "South Carolina", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "South Dakota", + "Rate": 86, + "Location": "Home", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "27", - "State": "region 2", - "Change": "-0.5" + "STATE": "Tennessee", + "Rate": 60, + "Location": "Home", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "26", - "State": "region 3", - "Change": "-.08" + "STATE": "Texas", + "Rate": 30, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "30", - "State": "region 4", - "Change": "0.8" + "STATE": "Utah", + "Rate": 54, + "Location": "Work", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "14", - "State": "region 5", - "Change": "0.5" + "STATE": "Vermont", + "Rate": 40, + "Location": "Home", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "25", - "State": "region 6", - "Change": "0.05" + "STATE": "Virgin Islands", + "Rate": 55, + "Location": "School", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "0", - "State": "region 7", - "Change": "0" + "STATE": "Virginia", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "14", - "State": "region 8", - "Change": "-1.2" + "STATE": "Washington", + "Rate": 62, + "Location": "Work", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "28", - "State": "region 9", - "Change": "1.5" + "STATE": "West Virginia", + "Rate": 25, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "12", - "State": "region 10", - "Change": "0.5" + "STATE": "Wyoming", + "Rate": 43, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" } ], - "dataFileName": "valid-region-data.json", + "dataFileName": "valid-data-map.csv", "dataFileSourceType": "file", "formattedData": [ { - "Current Week Positivity": "20", - "State": "REGION 1", - "Change": "0.2" + "STATE": "Overall", + "Rate": "55", + "Location": "Vehicle", + "URL": "https://www.cdc.gov" + }, + { + "STATE": "Alabama", + "Rate": 130, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Alaska", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "American Samoa", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Arizona", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Arkansas", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "California", + "Rate": 30, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Colorado", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Connecticut", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Deleware", + "Rate": "57", + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "DC", + "Rate": 60, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Florida", + "Rate": 30, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Georgia", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Guam", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Hawaii", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Idaho", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Illinois", + "Rate": 30, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Indiana", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Iowa", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Kansas", + "Rate": 57, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Kentucky", + "Rate": 60, + "Location": "NA", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Louisiana", + "Rate": 30, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Maine", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Marshall Islands", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Maryland", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Massachusetts", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Michigan", + "Rate": 12, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Micronesia", + "Rate": 65, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Minnesota", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Mississippi", + "Rate": 57, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Montana", + "Rate": 60, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Montana", + "Rate": 30, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Nebraska", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Nevada", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New Hampshire", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New Jersey", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New Mexico", + "Rate": 12, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "New York", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "North Carolina", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "North Dakota", + "Rate": 57, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Northern Mariana Islands", + "Rate": "60", + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Ohio", + "Rate": 88, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Oklahoma", + "Rate": 40, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Oregon", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Palau", + "Rate": 15, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Pennsylvania", + "Rate": 60, + "Location": "School", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Puerto Rico", + "Rate": 30, + "Location": "Work", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "Rhode Island", + "Rate": 40, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "South Carolina", + "Rate": 55, + "Location": "Home", + "URL": "https://www.cdc.gov/" + }, + { + "STATE": "South Dakota", + "Rate": 86, + "Location": "Home", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "27", - "State": "region 2", - "Change": "-0.5" + "STATE": "Tennessee", + "Rate": 60, + "Location": "Home", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "26", - "State": "region 3", - "Change": "-.08" + "STATE": "Texas", + "Rate": 30, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "30", - "State": "region 4", - "Change": "0.8" + "STATE": "Utah", + "Rate": 54, + "Location": "Work", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "14", - "State": "region 5", - "Change": "0.5" + "STATE": "Vermont", + "Rate": 40, + "Location": "Home", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "25", - "State": "region 6", - "Change": "0.05" + "STATE": "Virgin Islands", + "Rate": 55, + "Location": "School", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "0", - "State": "region 7", - "Change": "0" + "STATE": "Virginia", + "Rate": 57, + "Location": "School", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "14", - "State": "region 8", - "Change": "-1.2" + "STATE": "Washington", + "Rate": 62, + "Location": "Work", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "28", - "State": "region 9", - "Change": "1.5" + "STATE": "West Virginia", + "Rate": 25, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" }, { - "Current Week Positivity": "12", - "State": "region 10", - "Change": "0.5" + "STATE": "Wyoming", + "Rate": 43, + "Location": "Vehicle", + "URL": "https://www.cdc.gov/" } ], "dataDescription": { "horizontal": false, "series": false }, - "version": "4.24.11" + "version": "4.25.1" } \ No newline at end of file diff --git a/packages/map/index.html b/packages/map/index.html index 80ae96a74..5ce110e5b 100644 --- a/packages/map/index.html +++ b/packages/map/index.html @@ -18,7 +18,7 @@ -
+ @@ -28,12 +28,9 @@ - +
-
+ diff --git a/packages/map/src/components/Legend/components/Legend.tsx b/packages/map/src/components/Legend/components/Legend.tsx index 2a4c66d6a..a0d07c3f7 100644 --- a/packages/map/src/components/Legend/components/Legend.tsx +++ b/packages/map/src/components/Legend/components/Legend.tsx @@ -42,7 +42,7 @@ const Legend = forwardRef((props, ref) => { setAccessibleStatus, setRuntimeLegend, state, - viewport, + currentViewport: viewport, mapId } = useContext(ConfigContext) diff --git a/packages/map/src/components/UsaMap/components/TerritoriesSection.tsx b/packages/map/src/components/UsaMap/components/TerritoriesSection.tsx index 525ca1fea..c0b3c7a94 100644 --- a/packages/map/src/components/UsaMap/components/TerritoriesSection.tsx +++ b/packages/map/src/components/UsaMap/components/TerritoriesSection.tsx @@ -9,7 +9,7 @@ type TerritoriesSectionProps = { const TerritoriesSection: React.FC = ({ territories, logo, config }) => { const usTerritories = territories .filter(territory => { - return ['US-AS', 'US-GU', 'US-MP', 'US-PR', 'US-VI'].includes(territory.props.territory) + return ['US-AS', 'US-GU', 'US-MP', 'US-PR', 'US-VI'].includes(territory?.props?.territory) }) .sort((a, b) => { return a.props.territory.localeCompare(b.props.territory) @@ -17,7 +17,7 @@ const TerritoriesSection: React.FC = ({ territories, lo const freelyAssociatedStates = territories .filter(territory => { - return ['US-FM', 'US-MH', 'US-PW'].includes(territory.props.territory) + return ['US-FM', 'US-MH', 'US-PW'].includes(territory?.props?.territory) }) .sort((a, b) => { return a.props.territory.localeCompare(b.props.territory)