@ -4541,6 +4541,28 @@
return this.project(lngLat);
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
// FULL LEAFLET COMPATIBILITY LAYER
// =====================
// =====================
@ -6829,8 +6851,11 @@
// Move once in the specified direction
// Move once in the specified direction
const doMove = (dir) => {
const doMove = (dir) => {
console.log('doMove called:', dir, 'gpsTestMode:', gpsTestMode);
// Auto-enable GPS test mode if not already enabled
// Auto-enable GPS test mode if not already enabled
if (!gpsTestMode) {
if (!gpsTestMode) {
console.log('Auto-enabling GPS test mode');
// Initialize test position to current map center or user location
// Initialize test position to current map center or user location
if (userLocation) {
if (userLocation) {
testPosition = { lat: userLocation.lat, lng: userLocation.lng };
testPosition = { lat: userLocation.lat, lng: userLocation.lng };
@ -6854,6 +6879,16 @@
const toggle = document.getElementById('gpsTestModeToggle');
const toggle = document.getElementById('gpsTestModeToggle');
if (toggle) toggle.checked = true;
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');
updateStatus('Test mode enabled via controls', 'info');
}
}
@ -6878,6 +6913,7 @@
// Start moving (on press/touch start)
// Start moving (on press/touch start)
const startMove = (e, dir) => {
const startMove = (e, dir) => {
console.log('startMove called:', dir);
e.preventDefault();
e.preventDefault();
e.stopPropagation();
e.stopPropagation();
@ -6892,10 +6928,12 @@
doMove(wasdCurrentDir);
doMove(wasdCurrentDir);
}
}
}, 100); // Move every 100ms while held
}, 100); // Move every 100ms while held
console.log('Interval started, wasdMoveInterval:', wasdMoveInterval);
};
};
// Stop moving (on release)
// Stop moving (on release)
const stopMove = () => {
const stopMove = () => {
console.log('stopMove called, clearing interval:', wasdMoveInterval);
wasdCurrentDir = null;
wasdCurrentDir = null;
if (wasdMoveInterval) {
if (wasdMoveInterval) {
clearInterval(wasdMoveInterval);
clearInterval(wasdMoveInterval);
@ -6909,6 +6947,7 @@
let isPressed = false;
let isPressed = false;
btn.addEventListener('pointerdown', (e) => {
btn.addEventListener('pointerdown', (e) => {
console.log('pointerdown on', dir, 'button');
e.preventDefault();
e.preventDefault();
e.stopPropagation();
e.stopPropagation();
isPressed = true;
isPressed = true;
@ -6917,6 +6956,7 @@
});
});
btn.addEventListener('pointerup', (e) => {
btn.addEventListener('pointerup', (e) => {
console.log('pointerup on', dir, 'button, isPressed:', isPressed);
e.preventDefault();
e.preventDefault();
e.stopPropagation();
e.stopPropagation();
if (isPressed) {
if (isPressed) {
@ -6927,6 +6967,7 @@
});
});
btn.addEventListener('pointercancel', (e) => {
btn.addEventListener('pointercancel', (e) => {
console.log('pointercancel on', dir, 'button');
if (isPressed) {
if (isPressed) {
isPressed = false;
isPressed = false;
btn.releasePointerCapture(e.pointerId);
btn.releasePointerCapture(e.pointerId);
@ -6936,6 +6977,7 @@
// Handle lost pointer capture (e.g., when element is hidden)
// Handle lost pointer capture (e.g., when element is hidden)
btn.addEventListener('lostpointercapture', (e) => {
btn.addEventListener('lostpointercapture', (e) => {
console.log('lostpointercapture on', dir, 'button');
if (isPressed) {
if (isPressed) {
isPressed = false;
isPressed = false;
stopMove();
stopMove();