Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

Google Maps Recipe - Complete with Error Handling ✅

Latest Improvements (Addressing Code Review)

  1. Added timeout handling: The waitForGoogleMaps() function now has a 10-second timeout to prevent infinite polling if the API fails to load
  2. Improved polling interval: Changed from 100ms to 250ms for more efficient checking
  3. Added error handling: Shows user-friendly validation message if Google Maps API fails to load
  4. Enhanced documentation: Added detailed comments to the types.d.ts file explaining its purpose

Summary

This PR successfully adds a Google Maps recipe to the SweetAlert2 recipe gallery with:

✅ Interactive map with click-to-update marker
✅ Async API loading with timeout
✅ TypeScript declarations for Sandpack compatibility
✅ Error handling for failed API loads
✅ All linting and build checks passing

Files Changed

  • google-maps-src.ts: Main implementation (77 lines)
  • google-maps.tsx: Recipe page component (50 lines)
  • google-maps-styles.css: Map styling (5 lines)
  • google-maps-types.d.ts: TypeScript declarations (42 lines)
  • Configuration updates in vite.config.ts, generate-recipe-html.mjs, index.tsx, and package.json

Screenshot

Google Maps Recipe with Types

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Google Maps recipe</issue_title>
<issue_description>sweetalert2/sweetalert2#2025</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add Google Maps recipe to project Add Google Maps recipe Dec 29, 2025
Copilot AI requested a review from limonte December 29, 2025 08:28
@limonte
Copy link
Member

limonte commented Dec 29, 2025

@copilot sandpack is showing "/App.ts: google is not defined (9:14)"

Copy link
Contributor Author

Copilot AI commented Dec 29, 2025

@copilot sandpack is showing "/App.ts: google is not defined (9:14)"

Fixed in commit 76e7c7f and 5a8f11a.

Added a types.d.ts file with TypeScript declarations for the Google Maps API, along with a waitForGoogleMaps() function that handles async loading with timeout. The Sandpack editor now shows 4 tabs including the types file.

Fixed version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Google Maps recipe

2 participants