diff --git a/src/app/map-svg/map-svg.css b/src/app/map-svg/map-svg.css
index feba52d..7308abd 100644
--- a/src/app/map-svg/map-svg.css
+++ b/src/app/map-svg/map-svg.css
@@ -1,14 +1,8 @@
-.svg-container {
+.svg-object {
width: 100%;
- height: 100%;
- display: flex;
- justify-content: center;
- align-items: center;
-}
-
-:host ::ng-deep svg {
- max-width: 100%;
height: auto;
+ max-width: 100%;
+ pointer-events: all;
}
:host ::ng-deep .country-path {
diff --git a/src/app/map-svg/map-svg.html b/src/app/map-svg/map-svg.html
index 4af6af0..41749a4 100644
--- a/src/app/map-svg/map-svg.html
+++ b/src/app/map-svg/map-svg.html
@@ -1 +1 @@
-
+
diff --git a/src/app/map-svg/map-svg.ts b/src/app/map-svg/map-svg.ts
index 1623851..76e313a 100644
--- a/src/app/map-svg/map-svg.ts
+++ b/src/app/map-svg/map-svg.ts
@@ -1,5 +1,4 @@
import { Component, Output, EventEmitter, AfterViewInit, ElementRef } from '@angular/core';
-import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-map-svg',
@@ -10,38 +9,30 @@ import { HttpClient } from '@angular/common/http';
export class MapSvgComponent implements AfterViewInit {
@Output() countryClick = new EventEmitter();
- constructor(private http: HttpClient, private elementRef: ElementRef) {}
+ constructor(private elementRef: ElementRef) {}
ngAfterViewInit(): void {
- // Load SVG file and inject it into the component
- this.http.get('map-image.svg', { responseType: 'text' }).subscribe({
- next: (svgContent) => {
- const container = this.elementRef.nativeElement.querySelector('.svg-container');
- if (container) {
- container.innerHTML = svgContent;
- this.attachClickHandlers();
- }
- },
- error: (err) => {
- console.error('Failed to load SVG:', err);
- }
- });
+ // Wait for object to load
+ setTimeout(() => {
+ this.attachClickHandlers();
+ }, 500);
}
private attachClickHandlers(): void {
- const svgElement = this.elementRef.nativeElement.querySelector('svg');
- if (!svgElement) return;
+ const objectElement = this.elementRef.nativeElement.querySelector('object');
+ if (!objectElement || !objectElement.contentDocument) {
+ console.error('SVG object not loaded');
+ return;
+ }
- // Find all path elements with id attributes (country codes)
- const paths = svgElement.querySelectorAll('path[id]');
+ const svgDoc = objectElement.contentDocument;
+ const paths = svgDoc.querySelectorAll('path[id]');
paths.forEach((path: Element) => {
const countryCode = path.getAttribute('id');
if (countryCode) {
- // Add hover effect
path.setAttribute('class', 'country-path');
- // Add click handler
path.addEventListener('click', () => {
this.countryClick.emit(countryCode.toUpperCase());
});
diff --git a/src/app/map/map.html b/src/app/map/map.html
index 0bcaa72..763a1aa 100644
--- a/src/app/map/map.html
+++ b/src/app/map/map.html
@@ -2,6 +2,7 @@