Created
November 15, 2024 01:29
-
-
Save ekmett/968f30cc079c7d311f3667f88b00b0c2 to your computer and use it in GitHub Desktop.
Map of states by SSN starting digits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>SSN Ranges by State</title> | |
<style> | |
#map { | |
height: 600px; | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
function initMap() { | |
const map = new google.maps.Map(document.getElementById('map'), { | |
zoom: 4, | |
center: {lat: 39.8283, lng: -98.5795}, | |
mapTypeId: 'terrain' | |
}); | |
// Function to determine if a number is odd | |
function isOdd(n) { | |
return n % 2 !== 0; | |
} | |
// Function to get all leading digits from SSN ranges | |
function getLeadingDigits(ranges) { | |
return ranges.split(',').map(range => | |
range.trim().split('-').map(num => parseInt(num[0])) | |
).flat(); | |
} | |
// Function to determine color based on leading digits | |
function getColorForRanges(ranges) { | |
const leadingDigits = new Set(getLeadingDigits(ranges)); | |
const hasOdd = Array.from(leadingDigits).some(d => isOdd(d)); | |
const hasEven = Array.from(leadingDigits).some(d => !isOdd(d)); | |
if (hasOdd && hasEven) return '#FFFF00'; // Yellow for mixed | |
if (hasOdd) return '#FF0000'; // Red for odd | |
return '#00FF00'; // Green for even | |
} | |
// State data with SSN ranges - Updated with complete ranges | |
const stateData = { | |
'Alabama': {ranges: '416-424'}, | |
'Alaska': {ranges: '574'}, | |
'Arizona': {ranges: '526-527'}, | |
'Arkansas': {ranges: '429-432'}, | |
'California': {ranges: '545-573, 602-626'}, | |
'Colorado': {ranges: '521-524'}, | |
'Connecticut': {ranges: '040-049'}, | |
'Delaware': {ranges: '221-222'}, | |
'Florida': {ranges: '261-267, 589-595, 766-772'}, | |
'Georgia': {ranges: '252-260, 667-675'}, | |
'Hawaii': {ranges: '575-576, 750-751'}, | |
'Idaho': {ranges: '518-519'}, | |
'Illinois': {ranges: '318-361, 690-699'}, | |
'Indiana': {ranges: '303-317, 468-477'}, | |
'Iowa': {ranges: '478-485, 485-500'}, | |
'Kansas': {ranges: '509-515'}, | |
'Kentucky': {ranges: '400-407'}, | |
'Louisiana': {ranges: '433-439, 659-665'}, | |
'Maine': {ranges: '004-007'}, | |
'Maryland': {ranges: '212-220, 223-231'}, | |
'Massachusetts': {ranges: '010-034'}, | |
'Michigan': {ranges: '362-386, 373-386'}, | |
'Minnesota': {ranges: '468-477'}, | |
'Mississippi': {ranges: '425-428, 587-588'}, | |
'Missouri': {ranges: '486-500, 494-508'}, | |
'Montana': {ranges: '516-517'}, | |
'Nebraska': {ranges: '505-508'}, | |
'Nevada': {ranges: '530, 680, 681'}, | |
'New Hampshire': {ranges: '001-003'}, | |
'New Jersey': {ranges: '135-158, 151-158'}, | |
'New Mexico': {ranges: '525-525, 585, 648-649'}, | |
'New York': {ranges: '050-134, 089-134'}, | |
'North Carolina': {ranges: '237-246, 232, 681-690'}, | |
'North Dakota': {ranges: '501-502'}, | |
'Ohio': {ranges: '268-302, 284-302'}, | |
'Oklahoma': {ranges: '440-448, 445-448'}, | |
'Oregon': {ranges: '540-544, 545-573'}, | |
'Pennsylvania': {ranges: '159-211, 190-211'}, | |
'Rhode Island': {ranges: '035-039'}, | |
'South Carolina': {ranges: '247-251, 654-658'}, | |
'South Dakota': {ranges: '503-504'}, | |
'Tennessee': {ranges: '408-415, 756-763'}, | |
'Texas': {ranges: '449-467, 627-645'}, | |
'Utah': {ranges: '528-529, 646-647'}, | |
'Vermont': {ranges: '008-009'}, | |
'Virginia': {ranges: '223-231, 691-699'}, | |
'Washington': {ranges: '531-539, 540-544'}, | |
'West Virginia': {ranges: '232-236'}, | |
'Wisconsin': {ranges: '387-399, 744-749'}, | |
'Wyoming': {ranges: '520'} | |
}; | |
// Process state colors | |
for (let state in stateData) { | |
stateData[state].color = getColorForRanges(stateData[state].ranges); | |
} | |
// Load state boundaries GeoJSON | |
map.data.loadGeoJson( | |
'https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/us-states.json' | |
); | |
// Style the states based on SSN ranges | |
map.data.setStyle(function(feature) { | |
const stateName = feature.getProperty('name'); | |
const stateInfo = stateData[stateName]; | |
return { | |
fillColor: stateInfo ? stateInfo.color : '#GRAY', | |
fillOpacity: 0.7, | |
strokeWeight: 1, | |
strokeColor: '#000000' | |
}; | |
}); | |
// Add info windows on click | |
map.data.addListener('click', function(event) { | |
const stateName = event.feature.getProperty('name'); | |
const stateInfo = stateData[stateName]; | |
if (stateInfo) { | |
new google.maps.InfoWindow({ | |
content: `<strong>${stateName}</strong><br>SSN Ranges: ${stateInfo.ranges}`, | |
position: event.latLng | |
}).open(map); | |
} | |
}); | |
} | |
</script> | |
<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment