本帖最后由 980041382 于 2024-7-29 16:27 编辑
[JavaScript] 纯文本查看 复制代码 zoomInButton.addEventListener('click', () => {
scaleFactor += 0.2;
console.log(`Zooming in, new scaleFactor: ${scaleFactor}`);
updateMapDimensions();
updateMarkers();
});
zoomOutButton.addEventListener('click', () => {
scaleFactor = Math.max(1.0, scaleFactor - 0.2); // 防止缩小比例低于1
console.log(`Zooming out, new scaleFactor: ${scaleFactor}`);
updateMapDimensions();
updateMarkers();
});
[JavaScript] 纯文本查看 复制代码 let mapWidth, mapHeight;
const updateMapDimensions = () => {
mapWidth = (topRightX - topLeftX) * scaleFactor;
mapHeight = (bottomLeftY - topLeftY) * scaleFactor;
mapContainer.style.width = `${currentWidth * scaleFactor}px`;
mapContainer.style.height = `${currentHeight * scaleFactor}px`;
mapContainer.style.backgroundSize = `${currentWidth * scaleFactor}px ${currentHeight * scaleFactor}px`;
console.log(`Updated map dimensions: width=${mapWidth}, height=${mapHeight}`);
};
我执行放大按钮后。。图片确实会变大。。但是原本下面的图片没了 变成了白色 如图。。我应该怎么样设置属性呢? |