Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Google Maps integration and update dependencies #629

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions env.local
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-WSXY307CRR
NEXT_PUBLIC_GOOGLE_MAPS_KEY=AIzaSyB3mMuvl8IUlviRZiizBiX7uhsdIqunx94
1 change: 1 addition & 0 deletions env.production
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_GOOGLE_ANALYTICS_ID=G-WSXY307CRR
NEXT_PUBLIC_GOOGLE_MAPS_KEY=AIzaSyB3mMuvl8IUlviRZiizBiX7uhsdIqunx94
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@playwright/test": "^1.37.1",
"@tailwindcss/typography": "^0.5.2",
"@types/cookie": "^0.5.1",
"@types/google.maps": "^3.49.1",
"@types/google.maps": "^3.58.1",
"@types/jsonwebtoken": "^8.5.8",
"@types/marked": "^4.0.3",
"@types/node": "^18.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/components/ui/google-map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ type MapProps = google.maps.MapOptions;
const MyMap: React.FC<MapProps> = ({ ...options }) => {
return (
<Wrapper
apiKey="AIzaSyB3mMuvl8IUlviRZiizBiX7uhsdIqunx94"
apiKey={process.env.NEXT_PUBLIC_GOOGLE_MAPS_KEY || ''}
render={render}
>
<Map {...options}>
<Marker position={options.center} />
{options.center && <Marker position={options.center} />}
</Map>
</Wrapper>
);
};

export default MyMap;
export default MyMap;
42 changes: 23 additions & 19 deletions src/containers/contact-info/layout-02/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ type TProps = TSection & {
};
};

const ContactInfo = ({ data: { section_title, items, location } }: TProps) => {
const ContactInfo = ({ data: { section_title, items } }: TProps) => {
// Hardcoded Atlanta coordinates
const atlantaLocation = {
latitude: 33.7488,
longitude: -84.3877
};

return (
<Section className="contact-info-area" space="none">
<div className="tw-container">
Expand Down Expand Up @@ -61,26 +67,24 @@ const ContactInfo = ({ data: { section_title, items, location } }: TProps) => {
</div>
))}
</motion.div>
{location && (
<motion.div
className="tw-h-[300px] lg:tw-h-[400px]"
initial="offscreen"
whileInView="onscreen"
viewport={{ once: true, amount: 0.4 }}
variants={scrollUpVariants}
>
<GoogleMap
center={{
lat: location.latitude,
lng: location.longitude,
}}
zoom={14}
/>
</motion.div>
)}
<motion.div
className="tw-h-[300px] lg:tw-h-[400px]"
initial="offscreen"
whileInView="onscreen"
viewport={{ once: true, amount: 0.4 }}
variants={scrollUpVariants}
>
<GoogleMap
center={{
lat: atlantaLocation.latitude,
lng: atlantaLocation.longitude,
}}
zoom={14}
/>
</motion.div>
</div>
</Section>
);
};

export default ContactInfo;
export default ContactInfo;
18 changes: 18 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/// <reference types="@types/google.maps" />

declare global {
interface Window {
google: typeof google;
}
}

// Google Maps Types
export interface MapType extends google.maps.MapOptions {
onClick?: (e: google.maps.MapMouseEvent) => void;
children?: React.ReactNode;
}

export interface MarkerType extends google.maps.MarkerOptions {
onClick?: () => void;
}

export type IDType = string | number;

export interface ImageType {
Expand Down
15 changes: 12 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@
"@utils/*": ["utils/*"],
"@widgets/*": ["components/widgets/*"],
"@fonts/*": ["public/fonts/*"]
}
},
"types": ["google.maps"] // Add this line
},
"include": ["next-env.d.ts", "next.config.js", "src/**/*.ts", "src/**/*.tsx", "tailwind.config.js", "postcss.config.js", "next-sitemap.config.js"],
"include": [
"next-env.d.ts",
"next.config.js",
"src/**/*.ts",
"src/**/*.tsx",
"tailwind.config.js",
"postcss.config.js",
"next-sitemap.config.js"
],
"exclude": ["node_modules"]
}
}
Loading
Loading