section review page

This commit is contained in:
taDuc
2026-04-19 00:59:06 +07:00
parent bc98830871
commit 57a7843d80
3 changed files with 1156 additions and 146 deletions

View File

@@ -57,9 +57,11 @@ export function initSelect(
// Chọn feature theo click trái, hỗ trợ additive bằng Alt.
function onClick(e: maplibregl.MapLayerMouseEvent) {
if (getMode() !== "select") return;
const selectableLayers = getSelectableLayers();
if (!selectableLayers.length) return;
const features = map.queryRenderedFeatures(e.point, {
layers: [...SELECTABLE_LAYERS],
layers: selectableLayers,
}) as maplibregl.MapGeoJSONFeature[];
if (!features.length) {
@@ -75,11 +77,13 @@ export function initSelect(
// Mở menu thao tác khi click phải lên feature.
function onRightClick(e: maplibregl.MapLayerMouseEvent) {
if (getMode() !== "select") return;
const selectableLayers = getSelectableLayers();
if (!selectableLayers.length) return;
e.preventDefault(); // block browser menu
const features = map.queryRenderedFeatures(e.point, {
layers: [...SELECTABLE_LAYERS],
layers: selectableLayers,
}) as maplibregl.MapGeoJSONFeature[];
if (!features.length) return;
@@ -104,14 +108,23 @@ export function initSelect(
// Đổi cursor pointer khi hover lên đối tượng có thể chọn.
function onMove(e: maplibregl.MapLayerMouseEvent) {
if (getMode() !== "select") return;
const selectableLayers = getSelectableLayers();
if (!selectableLayers.length) {
map.getCanvas().style.cursor = "";
return;
}
const features = map.queryRenderedFeatures(e.point, {
layers: [...SELECTABLE_LAYERS],
layers: selectableLayers,
});
map.getCanvas().style.cursor = features.length ? "pointer" : "";
}
function getSelectableLayers(): string[] {
return SELECTABLE_LAYERS.filter((layerId) => Boolean(map.getLayer(layerId)));
}
map.on("click", onClick);
map.on("mousemove", onMove);
if (hasContextActions) {