fix: corrección de errores en mapa y filtros de horarios

This commit is contained in:
2026-02-27 21:24:26 -05:00
parent d33c4c4ab1
commit 8084032f25
4 changed files with 108 additions and 153 deletions

View File

@ -323,67 +323,44 @@ export function useGoogleMaps() {
}
function addHtmlMarker(
position: { lat: number; lng: number },
htmlContent: string,
offset: { x: number; y: number } = { x: 0, y: 0 }
position: { lat: number, lng: number },
html: string,
offset: { x: number, y: number } = { x: 0, y: 0 }
) {
if (!map.value) return null;
class CustomOverlay extends google.maps.OverlayView {
private div: HTMLElement | null = null;
private pos: google.maps.LatLng;
const overlay = new google.maps.OverlayView();
let container: HTMLDivElement | null = null;
constructor(pos: google.maps.LatLng) {
super();
this.pos = pos;
overlay.onAdd = function () {
container = document.createElement('div');
container.style.position = 'absolute';
container.innerHTML = html;
const panes = this.getPanes();
if (panes) panes.overlayMouseTarget.appendChild(container);
};
overlay.draw = function () {
const projection = this.getProjection();
if (!projection || !container) return;
const pos = projection.fromLatLngToDivPixel(new google.maps.LatLng(position.lat, position.lng));
if (pos) {
container.style.left = (pos.x + offset.x) + 'px';
container.style.top = (pos.y + offset.y) + 'px';
}
};
onAdd() {
const div = document.createElement('div');
div.style.position = 'absolute';
div.style.cursor = 'pointer';
div.innerHTML = htmlContent;
this.div = div;
const panes = this.getPanes();
panes?.overlayMouseTarget.appendChild(div);
overlay.onRemove = function () {
if (container && container.parentNode) {
container.parentNode.removeChild(container);
}
container = null;
};
draw() {
const overlayProjection = this.getProjection();
const point = overlayProjection.fromLatLngToDivPixel(this.pos);
if (point && this.div) {
this.div.style.left = (point.x + offset.x) + 'px';
this.div.style.top = (point.y + offset.y) + 'px';
}
}
onRemove() {
if (this.div) {
try {
// Safer element removal
if (this.div.parentNode) {
this.div.parentNode.removeChild(this.div);
} else {
this.div.remove();
}
} catch (e) {
console.warn('CustomOverlay: element already removed or parent mismatch', e);
}
this.div = null;
}
}
setPosition(newPos: { lat: number; lng: number }) {
this.pos = new google.maps.LatLng(newPos.lat, newPos.lng);
this.draw();
}
}
const overlay = new CustomOverlay(new google.maps.LatLng(position.lat, position.lng));
overlay.setMap(map.value);
registrarMarker(overlay);
registrarMarker(overlay as any);
// Track for cleanup
// Track in global overlay tracker
if (!globalOverlays.has(map.value)) {
globalOverlays.set(map.value, new Set());
}