diff --git a/index.html b/index.html index da7461b..ef931d3 100644 --- a/index.html +++ b/index.html @@ -4541,6 +4541,28 @@ return this.project(lngLat); }; + // ===================== + // MAPLIBRE MARKER COMPATIBILITY SHIMS + // ===================== + // Add Leaflet-style methods to MapLibre Marker prototype + + // Marker.getLatLng() - returns {lat, lng} object like Leaflet + if (!maplibregl.Marker.prototype.getLatLng) { + maplibregl.Marker.prototype.getLatLng = function() { + const lngLat = this.getLngLat(); + return { lat: lngLat.lat, lng: lngLat.lng }; + }; + } + + // Marker.setLatLng([lat, lng]) - accepts Leaflet-style coordinates + if (!maplibregl.Marker.prototype.setLatLng) { + maplibregl.Marker.prototype.setLatLng = function(latlng) { + const lng = Array.isArray(latlng) ? latlng[1] : latlng.lng; + const lat = Array.isArray(latlng) ? latlng[0] : latlng.lat; + return this.setLngLat([lng, lat]); + }; + } + // ===================== // FULL LEAFLET COMPATIBILITY LAYER // ===================== @@ -6829,8 +6851,11 @@ // Move once in the specified direction const doMove = (dir) => { + console.log('doMove called:', dir, 'gpsTestMode:', gpsTestMode); + // Auto-enable GPS test mode if not already enabled if (!gpsTestMode) { + console.log('Auto-enabling GPS test mode'); // Initialize test position to current map center or user location if (userLocation) { testPosition = { lat: userLocation.lat, lng: userLocation.lng }; @@ -6854,6 +6879,16 @@ const toggle = document.getElementById('gpsTestModeToggle'); if (toggle) toggle.checked = true; + // Force auto-center ON when entering test mode + if (!autoCenterMode) { + autoCenterMode = true; + const btn = document.getElementById('autoCenterBtn'); + if (btn) { + btn.textContent = 'Auto-Center: ON'; + btn.classList.add('active'); + } + } + updateStatus('Test mode enabled via controls', 'info'); } @@ -6878,6 +6913,7 @@ // Start moving (on press/touch start) const startMove = (e, dir) => { + console.log('startMove called:', dir); e.preventDefault(); e.stopPropagation(); @@ -6892,10 +6928,12 @@ doMove(wasdCurrentDir); } }, 100); // Move every 100ms while held + console.log('Interval started, wasdMoveInterval:', wasdMoveInterval); }; // Stop moving (on release) const stopMove = () => { + console.log('stopMove called, clearing interval:', wasdMoveInterval); wasdCurrentDir = null; if (wasdMoveInterval) { clearInterval(wasdMoveInterval); @@ -6909,6 +6947,7 @@ let isPressed = false; btn.addEventListener('pointerdown', (e) => { + console.log('pointerdown on', dir, 'button'); e.preventDefault(); e.stopPropagation(); isPressed = true; @@ -6917,6 +6956,7 @@ }); btn.addEventListener('pointerup', (e) => { + console.log('pointerup on', dir, 'button, isPressed:', isPressed); e.preventDefault(); e.stopPropagation(); if (isPressed) { @@ -6927,6 +6967,7 @@ }); btn.addEventListener('pointercancel', (e) => { + console.log('pointercancel on', dir, 'button'); if (isPressed) { isPressed = false; btn.releasePointerCapture(e.pointerId); @@ -6936,6 +6977,7 @@ // Handle lost pointer capture (e.g., when element is hidden) btn.addEventListener('lostpointercapture', (e) => { + console.log('lostpointercapture on', dir, 'button'); if (isPressed) { isPressed = false; stopMove();