@ -3909,21 +3909,37 @@
});
});
}
}
// Tool buttons
const toolButtons = {
select: document.getElementById('selectTool'),
split: document.getElementById('splitTool'),
draw: document.getElementById('drawTool'),
reshape: document.getElementById('reshapeTool'),
smooth: document.getElementById('smoothTool'),
geocache: document.getElementById('geocacheTool')
};
// Tool buttons - initialize later after DOM is ready
let toolButtons = {};
// Initialize tool buttons after DOM elements exist
function initializeToolButtons() {
toolButtons = {
select: document.getElementById('selectTool'),
split: document.getElementById('splitTool'),
draw: document.getElementById('drawTool'),
reshape: document.getElementById('reshapeTool'),
smooth: document.getElementById('smoothTool'),
geocache: document.getElementById('geocacheTool')
};
// Tool button event listeners
Object.keys(toolButtons).forEach(tool => {
if (toolButtons[tool]) {
toolButtons[tool].addEventListener('click', () => setTool(tool));
} else {
console.warn(`Tool button not found: ${tool}`);
}
});
}
// Set active tool
// Set active tool
function setTool(tool) {
function setTool(tool) {
currentTool = tool;
currentTool = tool;
Object.keys(toolButtons).forEach(t => {
Object.keys(toolButtons).forEach(t => {
toolButtons[t].classList.toggle('active', t === tool);
if (toolButtons[t]) {
toolButtons[t].classList.toggle('active', t === tool);
}
});
});
// Cancel any drawing in progress
// Cancel any drawing in progress
@ -3932,8 +3948,10 @@
}
}
// Show/hide tool-specific controls
// Show/hide tool-specific controls
document.getElementById('reshapeControls').style.display = tool === 'reshape' ? 'block' : 'none';
document.getElementById('smoothControls').style.display = tool === 'smooth' ? 'block' : 'none';
const reshapeControls = document.getElementById('reshapeControls');
const smoothControls = document.getElementById('smoothControls');
if (reshapeControls) reshapeControls.style.display = tool === 'reshape' ? 'block' : 'none';
if (smoothControls) smoothControls.style.display = tool === 'smooth' ? 'block' : 'none';
// Update cursor
// Update cursor
const container = map.getContainer();
const container = map.getContainer();
@ -3953,10 +3971,10 @@
}
}
}
}
// Tool button event listeners
Object.keys(toolButtons).forEach(tool => {
toolButtons[tool].addEventListener('click', () => setTool(tool) );
});
// Initialize tool buttons when DOM is ready
setTimeout(() => {
initializeToolButtons( );
}, 100 );
// Track class
// Track class
class Track {
class Track {