This is an Angular 18 application that displays an interactive world map where users can hover over countries to retrieve detailed information about them from the World Bank API.
https://world-map-app-tawny.vercel.app/map
The WorldMap application is a standalone Angular application that presents an SVG-based world map. When users hover over a country, the application fetches and displays relevant data including capital city, income level, region, and geographical coordinates.
Key Features:
- Interactive SVG world map
- Real-time country data from World Bank API
- Hover effects for enhanced user experience
- Modern Angular 18 standalone architecture
- Tailwind CSS for styling
This application follows Angular 18's modern standalone component architecture:
- Standalone Components: No NgModules required
- Reactive Programming: Uses RxJS Observables for API calls
- External API Integration: World Bank API for country data
- Modular Design: Separation of concerns with dedicated service layer
Purpose: Root component that serves as the application's entry point.
Key Details:
- Selector:
app-root
- Type: Standalone component
- Template: Contains only
<router-outlet></router-outlet>
- Styling: No custom styles (empty CSS file)
- Properties:
title
: Set to 'world-map'
Functionality:
- Acts as the shell for the entire application
- Uses Angular Router to render child components
- Minimal implementation focusing on routing delegation
Template Structure:
<router-outlet></router-outlet>
Purpose: Core component that renders the interactive world map and handles user interactions.
Key Details:
- Selector:
app-map
- Type: Standalone component
- Imports:
CommonModule
for Angular directives - Dependencies: Injects
ApiService
for data fetching
Properties:
country
: Object to store selected country information- Contains: capital, income, region, place, latitude, longitude
Methods:
- Purpose: Handles country selection events from map interaction
- Parameters:
event
: DOM event containing target country information
- Functionality:
- Extracts country ID from
event.target.id
- Retrieves country title from
event.target.getAttribute('title')
- Calls
ApiService.setCountryData()
with country ID - Updates local
country
object with API response - Adds the country's display name as
place
property
- Extracts country ID from
Template Features:
- Contains comprehensive SVG world map (1314 lines)
- Each country path has:
(mouseenter)="setCountryData($event)"
event binding- Unique
id
attribute (country code) title
attribute (country name)
- Responsive design with proper viewport settings
Styling:
- Hover effects defined in CSS
- Orange highlight on country hover
Purpose: Handles all external API communications with the World Bank API.
Key Details:
- Type: Injectable service with root-level provision
- Dependencies: Uses
HttpClient
for HTTP requests - API Base URL:
http://api.worldbank.org/v2/country/
Methods:
- Purpose: Makes HTTP GET request to World Bank API
- Parameters:
code
: ISO country code (e.g., 'US', 'CA', 'GB')
- Returns: Observable containing raw API response
- API URL Format:
http://api.worldbank.org/v2/country/{code}?format=JSON&per_page=300
- Features:
- Console logging for debugging
- JSON format specification
- High page limit (300) to ensure complete data
- Purpose: Processes and transforms raw API data into application-friendly format
- Parameters:
code
: ISO country code
- Returns: Observable containing processed country data
- Data Transformation:
- Extracts first country object from API response (
data[1][0]
) - Maps to standardized format:
{ capital: countryData.capitalCity, income: countryData.incomeLevel.value, region: countryData.region.value, countryLatitude: countryData.latitude, countryLongitude: countryData.longitude }
- Extracts first country object from API response (
- Pattern: Uses Subject/Observable pattern for reactive data flow
Purpose: Central configuration for the Angular application.
Key Details:
- Type: ApplicationConfig object
- Exports:
appConfig
constant
Providers Configuration:
- Router:
provideRouter(routes)
- Enables routing functionality - HTTP Client:
importProvidersFrom(HttpClientModule)
- Enables HTTP requests - Note: HttpClientModule shows as deprecated in IDE but remains functional
Purpose: Defines application routing structure.
Route Configuration:
- Default Route:
{ path: '', component: MapComponent }
- Behavior: Empty path redirects to MapComponent
- Type: Simple single-page application routing
Purpose: Application entry point and bootstrap configuration.
Functionality:
- Bootstraps
AppComponent
withappConfig
- Error handling for bootstrap failures
- Uses Angular's standalone bootstrapping approach
Purpose: Main HTML document template.
Key Features:
- Title: "WorldMap"
- Viewport: Responsive design configuration
- Base href: Set to "/"
- Favicon: References favicon.ico
- App Root:
<app-root></app-root>
element for Angular app
Purpose: Global stylesheet configuration.
Framework Integration:
- Tailwind CSS: Complete integration with all utilities
- Directives:
@tailwind base
,@tailwind components
,@tailwind utilities
Purpose: Map-specific styling.
Hover Effects:
path:hover {
fill: orange;
}
Purpose: Tailwind CSS customization.
Configuration:
- Content: Scans all HTML and TypeScript files in src
- Theme: Default theme with extension capability
- Plugins: Empty array (no additional plugins)
Runtime Dependencies:
- Angular 18.1.0 (complete framework)
- RxJS 7.8.0 (reactive programming)
- Zone.js 0.14.3 (change detection)
- TypeScript 5.5.2 (type safety)
Development Dependencies:
- Angular CLI 18.1.4 (development tools)
- Tailwind CSS 3.4.10 (utility-first CSS)
- PostCSS & Autoprefixer (CSS processing)
- Karma & Jasmine (testing framework)
Key Settings:
- Output Path:
dist/world-map
- Source Root:
src
- Prefix:
app
- Build Tool: Angular DevKit Application Builder
- Assets: Public folder contents
- Styles: Global styles.css only
- Scripts: No additional scripts
Build Budgets:
- Initial Bundle: 500kB warning, 1MB error
- Component Styles: 2kB warning, 4kB error
# Development server
ng serve
# Production build
ng build
# Unit tests
ng test
# Component generation
ng generate component component-name
# Service generation
ng generate service service-name
world-map/
├── src/
│ ├── app/
│ │ ├── map/ # Map component
│ │ │ ├── map.component.ts # Map logic & interaction
│ │ │ ├── map.component.html # SVG world map (1314 lines)
│ │ │ ├── map.component.css # Map-specific styles
│ │ │ └── map.component.spec.ts # Unit tests
│ │ ├── api.service.ts # World Bank API integration
│ │ ├── api.service.spec.ts # Service unit tests
│ │ ├── app.component.ts # Root component
│ │ ├── app.component.html # Router outlet template
│ │ ├── app.component.css # Root component styles
│ │ ├── app.component.spec.ts # Root component tests
│ │ ├── app.config.ts # Application configuration
│ │ └── app.routes.ts # Routing configuration
│ ├── index.html # Main HTML template
│ ├── main.ts # Application bootstrap
│ └── styles.css # Global Tailwind CSS
├── public/
│ └── favicon.ico # Application icon
├── angular.json # Angular CLI configuration
├── package.json # Dependencies & scripts
├── tailwind.config.js # Tailwind CSS configuration
├── tsconfig.json # TypeScript configuration
├── tsconfig.app.json # App-specific TypeScript config
└── README.md # This documentation
- User Interaction: User hovers over country in SVG map
- Event Handling:
setCountryData()
method triggered with mouse event - Data Extraction: Country ID and name extracted from DOM event
- API Call:
ApiService.setCountryData()
called with country code - HTTP Request: Service makes request to World Bank API
- Data Processing: Raw API response transformed to application format
- UI Update: Component updates with country information
- Display: Country data displayed to user
World Bank API Details:
- Base URL:
http://api.worldbank.org/v2/country/
- Format: JSON
- Response Structure: Array with metadata and country data
- Data Fields Used:
capitalCity
: Capital city nameincomeLevel.value
: Economic income classificationregion.value
: Geographic regionlatitude
: Geographic latitudelongitude
: Geographic longitude
Test Files Included:
app.component.spec.ts
: Root component testsmap.component.spec.ts
: Map component testsapi.service.spec.ts
: API service tests
Testing Framework:
- Jasmine: Test framework
- Karma: Test runner
- Angular Testing Utilities: Component testing tools
Potential Improvements:
- Error Handling: Add comprehensive error handling for API failures
- Loading States: Implement loading indicators during API calls
- Caching: Add response caching for better performance
- Accessibility: Enhance keyboard navigation and screen reader support
- Mobile Optimization: Improve touch interactions for mobile devices
- Additional Data: Integrate more country statistics and information
- Search Functionality: Add country search capability
- Zoom Controls: Implement map zoom and pan features