import { Component } from '@angular/core'; import { Control, DomEvent, DomUtil, icon, Icon, latLng, Layer, Map, MapOptions, Marker, tileLayer } from 'leaflet'; import { BusinessListing, CommercialPropertyListing } from '../../../../../bizmatch-server/src/models/db.model'; @Component({ selector: 'app-base-details', template: ``, standalone: true, imports: [], }) export abstract class BaseDetailsComponent { // Leaflet-Map-Einstellungen mapOptions: MapOptions; mapLayers: Layer[] = []; mapCenter: any; mapZoom: number = 13; // Standardzoomlevel protected listing: BusinessListing | CommercialPropertyListing; constructor() { this.mapOptions = { layers: [ tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors', }), ], zoom: this.mapZoom, center: latLng(0, 0), // Platzhalter, wird später gesetzt }; } protected configureMap() { const latitude = this.listing.location.latitude; const longitude = this.listing.location.longitude; if (latitude !== null && latitude !== undefined && longitude !== null && longitude !== undefined) { this.mapCenter = latLng(latitude, longitude); // Build address string from available location data const addressParts = []; if (this.listing.location.housenumber) addressParts.push(this.listing.location.housenumber); if (this.listing.location.street) addressParts.push(this.listing.location.street); if (this.listing.location.name) addressParts.push(this.listing.location.name); else if (this.listing.location.county) addressParts.push(this.listing.location.county); if (this.listing.location.state) addressParts.push(this.listing.location.state); if (this.listing.location.zipCode) addressParts.push(this.listing.location.zipCode); const fullAddress = addressParts.join(', '); const marker = new Marker([latitude, longitude], { icon: icon({ ...Icon.Default.prototype.options, iconUrl: 'assets/leaflet/marker-icon.png', iconRetinaUrl: 'assets/leaflet/marker-icon-2x.png', shadowUrl: 'assets/leaflet/marker-shadow.png', }), }); // Add popup to marker with address if (fullAddress) { marker.bindPopup(`