Locations for Outline-based Maps in JavaScript

How to specify country codes, names, and US states for outline-based maps


Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Try Plotly Studio now.

With outline-based maps, you can visualize data for specific regions using the locations and locationmode parameters.

The following map types in Plotly.js support these parameters:

  • choropleth - color regions based on data values
  • scattergeo - show markers at geographic locations

The locations parameter accepts region identifiers and the locationmode parameter controls how those identifiers are interpreted:

  • 'ISO-3' - three-letter ISO country codes (for example, 'USA', 'CAN', 'GBR')
  • 'USA-states' - two-letter US state abbreviations (for example, 'CA', 'TX', 'NY')
  • 'country names' - full country names (for example, 'United States')

Set locationmode: 'ISO-3' to use three-letter ISO country codes in locations.

var data = [{
    type: 'choropleth',
    locations: ['USA', 'CAN', 'MEX', 'BRA', 'RUS'],
    locationmode: 'ISO-3',
    z: [100, 85, 72, 95, 68],
    colorscale: 'Viridis'
}];

var layout = {
    title: 'Choropleth with ISO-3 Country Codes',
    geo: {
        projection: {
            type: 'natural earth'
        }
    }
};

Plotly.newPlot('myDiv', data, layout);

The following ISO codes are supported when locationmode='ISO-3':

Codes marked † are only present in the higher-resolution map data. Since geo.resolution defaults to 110, plotting one of those locations also needs resolution: 50 on the geo subplot, or the location is skipped and nothing is drawn for it.

Rows marked (grouped with ...) are territories the map data draws inside another country's feature, listed here so the code is easy to find. Plotting one shades that whole country, and the territory name itself is not accepted as a value for locationmode: 'country names'.

Name ISO Code
AfghanistanAFG
Aksai ChinXAC
Åland IslandsALA
AlbaniaALB
AlgeriaDZA
American SamoaASM †
AndorraAND †
AngolaAGO
AnguillaAIA †
AntarcticaATA
Antigua and BarbudaATG †
ArgentinaARG
ArmeniaARM
ArubaABW †
Arunachal PradeshXAP
AustraliaAUS
AustriaAUT
AzerbaijanAZE
Azores Islands (grouped with Portugal)PRT
BahamasBHS
BahrainBHR †
BangladeshBGD
BarbadosBRB †
BelarusBLR
BelgiumBEL
BelizeBLZ
BeninBEN
BermudaBMU †
BhutanBTN
Bir TawilXBT
Bolivia (Plurinational State of)BOL
BonaireBES †
Bosnia and HerzegovinaBIH
BotswanaBWA
Bouvet IslandBVT †
BrazilBRA
British Virgin IslandsVGB †
Brunei DarussalamBRN
BulgariaBGR
Burkina FasoBFA
BurundiBDI
Cabo VerdeCPV
CambodiaKHM
CameroonCMR
CanadaCAN
Canary Islands (grouped with Spain)ESP
Cayman IslandsCYM †
Central African RepublicCAF
ChadTCD
Chagos Archipelago (grouped with Mauritius)MUS
ChileCHL
ChinaCHN
Christmas IslandCXR †
Cocos (Keeling) IslandsCCK †
ColombiaCOL
ComorosCOM
CongoCOG
Cook IslandsCOK †
Costa RicaCRI
Côte d'IvoireCIV
CroatiaHRV
CubaCUB
CuraçaoCUW †
CyprusCYP
CzechiaCZE
Democratic People's Republic of KoreaPRK
Democratic Republic of the CongoCOD
DenmarkDNK
DjiboutiDJI
DominicaDMA
Dominican RepublicDOM
EcuadorECU
EgyptEGY
El SalvadorSLV
Equatorial GuineaGNQ
EritreaERI
EstoniaEST
EswatiniSWZ
EthiopiaETH
Falkland Islands (Malvinas)FLK
Faroe IslandsFRO †
FijiFJI
FinlandFIN
FranceFRA
French GuianaGUF
French PolynesiaPYF
French Southern TerritoriesATF
GabonGAB
Galápagos Islands (grouped with Ecuador)ECU
GambiaGMB
Gaza (grouped with State of Palestine)PSE
GeorgiaGEO
GermanyDEU
GhanaGHA
GibraltarGIB †
GreeceGRC
GreenlandGRL
GrenadaGRD †
GuadeloupeGLP
GuamGUM
GuatemalaGTM
GuernseyGGY †
GuineaGIN
Guinea-BissauGNB
GuyanaGUY
HaitiHTI
Halaib TriangleXHT
Heard Island and McDonald IslandsHMD †
HondurasHND
Hong KongHKG †
HungaryHUN
IcelandISL
Ilemi TriangleXIT
IndiaIND
IndonesiaIDN
Iran (Islamic Republic of)IRN
IraqIRQ
IrelandIRL
Isle of ManIMN †
IsraelISR
ItalyITA
JamaicaJAM
Jammu and KashmirXJK
JapanJPN
JerseyJEY †
JordanJOR
KazakhstanKAZ
KenyaKEN
Kingdom of the NetherlandsNLD
KiribatiKIR †
KuwaitKWT
KyrgyzstanKGZ
Lao People's Democratic RepublicLAO
LatviaLVA
LebanonLBN
LesothoLSO
LiberiaLBR
LibyaLBY
LiechtensteinLIE †
LithuaniaLTU
LuxembourgLUX
MacaoMAC †
MadagascarMDG
Madeira Island (grouped with Portugal)PRT
MalawiMWI
MalaysiaMYS
MaldivesMDV †
MaliMLI
MaltaMLT †
Marshall IslandsMHL †
MartiniqueMTQ
MauritaniaMRT
MauritiusMUS
MayotteMYT †
MexicoMEX
Micronesia (Federated States of)FSM †
MonacoMCO †
MongoliaMNG
MontenegroMNE
MontserratMSR †
MoroccoMAR
MozambiqueMOZ
MyanmarMMR
NamibiaNAM
NauruNRU †
NepalNPL
New CaledoniaNCL
New ZealandNZL
NicaraguaNIC
NigerNER
NigeriaNGA
NiueNIU †
Norfolk IslandNFK †
North MacedoniaMKD
Northern Mariana IslandsMNP †
NorwayNOR
OmanOMN
PakistanPAK
PalauPLW †
PanamaPAN
Papua New GuineaPNG
ParaguayPRY
PeruPER
PhilippinesPHL
PitcairnPCN †
PolandPOL
PortugalPRT
Puerto RicoPRI
QatarQAT
Republic of KoreaKOR
Republic of MoldovaMDA
RéunionREU
RomaniaROU
Russian FederationRUS
RwandaRWA
SabaBES †
Saint BarthélemyBLM †
Saint HelenaSHN †
Saint Kitts and NevisKNA †
Saint LuciaLCA †
Saint MartinMAF †
Saint Pierre and MiquelonSPM †
Saint Vincent and the GrenadinesVCT †
SamoaWSM
Sao Tome and PrincipeSTP
Saudi ArabiaSAU
SenegalSEN
SerbiaSRB
SeychellesSYC †
Sierra LeoneSLE
SingaporeSGP †
Sint EustatiusBES †
Sint MaartenSXM †
SlovakiaSVK
SloveniaSVN
Solomon IslandsSLB
SomaliaSOM
South AfricaZAF
South Georgia and the South Sandwich IslandsSGS
South SudanSSD
SpainESP
Sri LankaLKA
SudanSDN
SurinameSUR
Svalbard and Jan Mayen IslandsSJM
SwedenSWE
SwitzerlandCHE
Syrian Arab RepublicSYR
TaiwanTWN
TajikistanTJK
ThailandTHA
Timor-LesteTLS
TogoTGO
TokelauTKL †
TongaTON †
Trinidad and TobagoTTO
TunisiaTUN
TürkiyeTUR
TurkmenistanTKM
Turks and Caicos IslandsTCA †
TuvaluTUV †
UgandaUGA
UkraineUKR
United Arab EmiratesARE
United Kingdom of Great Britain and Northern IrelandGBR
United Republic of TanzaniaTZA
United States of AmericaUSA
United States Virgin IslandsVIR †
UruguayURY
UzbekistanUZB
VanuatuVUT
Venezuela (Bolivarian Republic of)VEN
Viet NamVNM
West Bank (grouped with State of Palestine)PSE
Western SaharaESH
YemenYEM
ZambiaZMB
ZimbabweZWE

View full list of ISO-3 codes

Set locationmode: 'USA-states' to use two-letter US state abbreviations in locations.

var data = [{
    type: 'choropleth',
    locations: ['CA', 'TX', 'NY', 'FL', 'IL'],
    locationmode: 'USA-states',
    z: [95, 88, 92, 85, 78],
    colorscale: 'Reds'
}];

var layout = {
    title: 'USA States Choropleth',
    geo: {
        scope: 'usa'
    }
};

Plotly.newPlot('myDiv', data, layout);

The following state codes are supported when locationmode='USA-states':

State Code
AlabamaAL
AlaskaAK
ArizonaAZ
ArkansasAR
CaliforniaCA
ColoradoCO
ConnecticutCT
DelawareDE
District of ColumbiaDC
FloridaFL
GeorgiaGA
HawaiiHI
IdahoID
IllinoisIL
IndianaIN
IowaIA
KansasKS
KentuckyKY
LouisianaLA
MaineME
MarylandMD
MassachusettsMA
MichiganMI
MinnesotaMN
MississippiMS
MissouriMO
MontanaMT
NebraskaNE
NevadaNV
New HampshireNH
New JerseyNJ
New MexicoNM
New YorkNY
North CarolinaNC
North DakotaND
OhioOH
OklahomaOK
OregonOR
PennsylvaniaPA
Rhode IslandRI
South CarolinaSC
South DakotaSD
TennesseeTN
TexasTX
UtahUT
VermontVT
VirginiaVA
WashingtonWA
West VirginiaWV
WisconsinWI
WyomingWY

Set locationmode: 'country names' to use full country names in locations.

Names are resolved by country-iso-search, which matches a country's name, its ISO-3166 and UN M49 codes, and a curated set of aliases — historical and native names, and common alternates. Matching ignores case, accents, and punctuation, so 'Cote d'Ivoire', 'Türkiye', and 'St. Kitts and Nevis' all resolve. See the library's country list for every accepted name and alias. A name that doesn't resolve is logged to the console and that location is skipped.

var data = [{
    type: 'choropleth',
    locations: ['United States', 'Canada', 'United Kingdom'],
    locationmode: 'country names',
    z: [1, 1, 1],
    colorscale: [[0, '#636efa'], [1, '#636efa']],
    showscale: false
}];

var layout = {
    title: 'Choropleth with Country Names'
};

Plotly.newPlot('myDiv', data, layout);