The SVG world map is the primary navigation surface in Country-Click. It is embedded as inline SVG directly in the PHP page (Documentation 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.
index.php), sitting inside a responsive flex container alongside the country info panel. Each clickable country is represented by an <a> element with the CSS class country and an xlink:title attribute that holds the country’s English name. Clicking any highlighted region sends that name to the PHP backend, which queries the REST Countries API and renders the result.
How map clicks work
When the page loads,getname.js selects every element with the class .country using document.querySelectorAll() and attaches a click event listener to each one. When a user clicks a country shape, the listener:
- Calls
event.preventDefault()to stop the browser from following thexlink:href="#"link. - Reads the
xlink:titleattribute value from the clicked element — this is the country’s English name. - Dynamically creates a hidden HTML
<form>withmethod="POST"and a single hidden<input>field namedtitulo, setting its value to the country name. - Appends the form to
document.bodyand immediately callsform.submit(), sending the country name to the PHP backend via POST.
GetNameController::clickCountries() reads $_POST['titulo'] to retrieve the submitted name. If $_POST['titulo'] is not set (no map click occurred), the method returns an empty string.
getname.js
Supported countries
The inline SVG includes<a class="country"> elements for major countries and territories across all continents. The following representative examples are drawn directly from the xlink:title values present in the SVG:
| Region | Countries |
|---|---|
| Americas | Greenland, Canada, United States of America, Brazil, Argentina, Chile, Colombia, Venezuela, Peru, Bolivia, Paraguay, Uruguay, Mexico |
| Europe | Russia, Norway, Finland, Sweden, United Kingdom, France, Spain, Germany, Italy, Poland |
| Africa | Nigeria, Ethiopia, South Africa, Angola, Namibia, Zambia, Zimbabwe, Mozambique, Madagascar, Botswana, Malawi |
| Asia | China, India, Japan, Indonesia, East Timor |
| Oceania | Australia, New Zealand |
Visual styling
Clickable countries use the CSS class.country, which is styled with Tailwind utility classes:
1.003), providing a subtle but clear interactive affordance. The transition-transform duration-300 class ensures the scale change animates smoothly over 300 ms. Countries that are part of the SVG but do not carry the country class are rendered as static decorative paths and do not respond to click events.