Skip to content

Commit

Permalink
Update Objects.tsx
Browse files Browse the repository at this point in the history
Bug fix: Single clicks are not allowed because the function requires extent to work.
  • Loading branch information
wlfrdssn authored Dec 25, 2024
1 parent 9769c02 commit 2082a51
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/tools/Objects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,25 @@ export default function Objects(): JSX.Element {
cursor: "crosshair",
});
interaction.on("extentchangeend", ({ extent }: { extent: Extent }) => {
const locations = mapExtentToDescriptionLocations(
extent,
map.getView().getProjection(),
(selectedCourse?.controls.length || 0) + 2
);
addSpecialObject(
{
kind: "descriptions",
locations,
isAllCourses: false,
},
selectedCourse.id
);
const objects = useEvent.getState().specialObjects;
setSelectedObjectId(objects[objects.length - 1].id);
setMode("edit");
if (extent){
const locations = mapExtentToDescriptionLocations(
extent,
map.getView().getProjection(),
(selectedCourse?.controls.length || 0) + 2
);
addSpecialObject(
{
kind: "descriptions",
locations,
isAllCourses: false,
},
selectedCourse.id
);
const objects = useEvent.getState().specialObjects;
setSelectedObjectId(objects[objects.length - 1].id);
setMode("edit");
}
else alert("Single clicks are not allowed.")
});
map.addInteraction(interaction);

Expand Down

0 comments on commit 2082a51

Please sign in to comment.