The SVG world map in Country-Click is embedded directly inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/Countries-WebPage/llms.txt
Use this file to discover all available pages before exploring further.
src/index.php. Each clickable country is an <a> element with class country and an xlink:title attribute set to the country’s English name. Adding a new country to the map means inserting a new <a class="country"> element with the correct SVG path geometry inside the existing map group. No JavaScript changes are required — the existing click handler reads the xlink:title attribute and sends it to the REST Countries API automatically.
How existing countries are structured
Every clickable country in the SVG follows the same pattern. Here is a representative example taken directly fromindex.php:
index.php (SVG excerpt)
<a> element:
| Attribute | Value | Purpose |
|---|---|---|
class="country" | Fixed string | Applies the Tailwind fill and hover styles defined in src/input.css |
xlink:href="#" | Fixed string # | Keeps the element as a non-navigating link; the click is handled by JavaScript |
xlink:title="ExactEnglishName" | Country name | The name sent to the REST Countries API. Must match a valid English or official name in the REST Countries database |
.country class in src/input.css applies fill-brown-hard, hover:fill-brown-medium, and a subtle scale transition to every element that carries it, so a new country will automatically inherit the same visual treatment as existing ones without any additional CSS.
Finding SVG path data
Each country’s shape is an SVG<path> element whose d attribute contains move, line, and curve commands. The map in index.php uses the following coordinate system:
- viewBox:
0 0 1920.000000 1152.000000 - Group transform:
translate(0.000000,1152.000000) scale(0.100000,-0.100000)
-0.100000 Y-scale) and scales path coordinates down by a factor of ten relative to the internal coordinate space. Any path you add must use coordinates that match this existing system — you cannot mix in paths from an SVG with a different viewBox or transform without adjusting the coordinates.
A practical approach for obtaining compatible path data:
- Extract country paths from a world SVG dataset such as Natural Earth at 1:110m or 1:50m scale.
- Transform the coordinates to match the existing viewBox scale using an SVG editor (Inkscape, Figma) or a coordinate-mapping script.
- Verify the path visually by placing it in the
<g>group and checking alignment against neighbouring countries in a browser.
Step-by-step: adding a country
Identify the exact country name in the REST Countries API
The If the response is a JSON array containing country data, the name is valid. If it returns
xlink:title value is passed verbatim to https://restcountries.com/v3.1/name/{name}. Test the name before adding it:{"status":404,"message":"Not Found"}, try the official name (for example, "Democratic Republic of the Congo" instead of "Congo").Obtain the SVG path d attribute
Find or generate an SVG
<path> for the territory whose coordinates align with the existing map coordinate system (viewBox 0 0 1920 1152, group transform translate(0,1152) scale(0.1,-0.1)). Verify the path visually before inserting it.Locate the map group in index.php
Open All
src/index.php and find the <g> element that contains all existing country paths. It begins with:index.php
<a class="country"> elements must be placed inside this group. The fill="#000000" on the group is overridden by the .country Tailwind class on each individual <a>.Add the new <a> element inside the <g> group
Insert your new country element anywhere inside the
<g> group. Order within the group does not affect functionality, but keeping countries geographically grouped makes the file easier to maintain:index.php
Verifying the country name
Thexlink:title value is passed directly to the REST Countries API endpoint https://restcountries.com/v3.1/name/{name}. You can confirm a name is valid before editing any files:
"Ivory Coast" may need to be entered as "Côte d'Ivoire" depending on the API version. The existing map uses names like "United States of America", "People's Republic of China", "Democratic Republic of the Congo", and "Republic of the Congo" — match the level of specificity the API expects.
Countries without region images
The Then add the corresponding image file to
menu() method in src/controller/ApiConsumer.php uses a switch statement to select a region illustration image based on the region field returned by the REST Countries API. The current switch covers five regions: Africa, Americas, Asia, Europe, and Oceania.If you add a country whose API response returns a region not covered by the switch — for example "Antarctic" — the $imagenReg variable will never be assigned, and PHP will emit an undefined variable warning when it tries to render the info panel.To fix this, add a new case to the switch in ApiConsumer::menu():ApiConsumer.php
src/resources/img/. The filename and path must match the value you assign to $imagenReg.