Skip to content

Commit

Permalink
Fix map centering && add offset params
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyula Kiri committed Apr 12, 2024
1 parent 05e8c00 commit 4295d36
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 4 additions & 0 deletions packages/admin/src/types/kiosk.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export const WidgetConfigFields: Record<WidgetName, WidgetConfigField[]> = {
map: [
{ name: 'radius', type: 'number', label: 'Hatósugár' },
{ name: 'zoom', type: 'number', label: 'Nagyítás' },
{ name: 'xOffset', type: 'number', label: 'X eltolás' },
{ name: 'yOffset', type: 'number', label: 'Y eltolás' },
],
};

Expand Down Expand Up @@ -156,6 +158,8 @@ export interface MapConfig extends WidgetConfigBase {
name: 'map';
radius: number;
zoom: number;
yOffset: number;
xOffset: number;
}

export type GridSettings = {
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/types/kiosk.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export interface BikeConfig extends WidgetConfigBase {
export interface MapConfig extends WidgetConfigBase {
name: 'map';
radius: number;
zoom: number;
yOffset: number;
xOffset: number;
}

export type GridSettings = {
Expand Down
22 changes: 16 additions & 6 deletions packages/client/src/components/widgets/MapWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function MapWidget() {
useInterval(async () => {
await refetch();
}, 5000);
const mapWidth = '1800px';
const mapWidth = '2000px';
const {
config: {
meta: { coordinates },
Expand Down Expand Up @@ -51,10 +51,20 @@ export function MapWidget() {
<IFrameContainer
src={src.replace('%2C', ',').replace('.html', '.html#')} // # nélkül nem működik, Köszönd Gábornak xd
style={{
left: -1420 + 240 * (config.grid.column.end - config.grid.column.start - 1), // haha, fix nem ták :DDD
top: -430 + 120 * (config.grid.row.end - config.grid.row.start - 1),
left:
-760 * devicePixelRatio +
1050 * (devicePixelRatio / 2 - 1) +
(devicePixelRatio > 1.75 ? 120 : 160) *
(config.grid.column.end - config.grid.column.start - 1) *
devicePixelRatio +
config.xOffset, // haha, fix nem ták :DDD
top:
-300 * devicePixelRatio +
210 * (devicePixelRatio / 2 - 1) +
70 * (config.grid.row.end - config.grid.row.start - 1) * devicePixelRatio +
config.yOffset,
}}
></IFrameContainer>
></IFrameContainer>{' '}
<SponsorText>
<RealCity size={35} />
</SponsorText>
Expand All @@ -72,9 +82,9 @@ const ContentContainer = styled.div`
const IFrameContainer = styled.iframe`
position: absolute;
/* Adjust this value to crop from the left half */
width: 2560px;
width: 2760px;
/* Width of the iframe */
height: 1080px;
height: 1440px;
/* Height of the iframe */
border: none;
`;
Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/types/widget.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export interface MapConfig extends WidgetConfigBase {
name: 'map';
radius: number;
zoom: number;
yOffset: number;
xOffset: number;
}

export type GridSettings = {
Expand Down

0 comments on commit 4295d36

Please sign in to comment.