Skip to content

Commit

Permalink
feat: spread all overlay properties to overlay generation
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Aug 31, 2023
1 parent 1396850 commit 0577728
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion elements/map/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
]);
document.querySelector("eox-map").addSelect("regions", {
id: "selectInteraction",
tooltip: "eox-map-tooltip",
overlay: {
element: "eox-map-tooltip",
offset: [0, 30],
},
condition: "pointermove",
layer: {
type: "Vector",
Expand Down
9 changes: 5 additions & 4 deletions elements/map/src/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function addSelect(
throw Error(`Interaction with id: ${options.id} already exists.`);
}

const tooltip: EOxMapTooltip = EOxMap.querySelector(options.tooltip);
const tooltip: HTMLElement = EOxMap.querySelector(options.overlay?.element);

let overlay: Overlay;
let selectedFid: string | number = null;
Expand All @@ -28,11 +28,12 @@ export async function addSelect(

if (tooltip) {
overlay = new Overlay({
element: tooltip,
position: undefined,
offset: [0, -30],
positioning: "top-center",
className: "eox-map-tooltip",
...options.overlay,
element: EOxMap.querySelector(options.overlay.element),
});
map.addOverlay(overlay);
}
Expand Down Expand Up @@ -105,8 +106,8 @@ export async function addSelect(

if (overlay) {
overlay.setPosition(feature ? event.coordinate : null);
if (feature) {
tooltip.renderContent(feature.getProperties());
if (feature && (<EOxMapTooltip>tooltip).renderContent) {
(<EOxMapTooltip>tooltip).renderContent(feature.getProperties());
}
}

Expand Down
4 changes: 3 additions & 1 deletion elements/map/test/hoverInteraction.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ describe("select interaction with hover", () => {
eoxMap
.addSelect("regions", {
id: "selectInteraction",
tooltip: "eox-map-tooltip",
overlay: {
element: "eox-map-tooltip",
},
condition: "pointermove",
layer: {
type: "Vector",
Expand Down

0 comments on commit 0577728

Please sign in to comment.