sweetalert2.github.io
sweetalert2.github.io copied to clipboard
Add Google Maps recipe
Google Maps Recipe - Complete with Error Handling ✅
Latest Improvements (Addressing Code Review)
-
Added timeout handling: The
waitForGoogleMaps()function now has a 10-second timeout to prevent infinite polling if the API fails to load - Improved polling interval: Changed from 100ms to 250ms for more efficient checking
- Added error handling: Shows user-friendly validation message if Google Maps API fails to load
- 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
Original prompt
This section details on the original issue you should resolve
<issue_title>Add Google Maps recipe</issue_title> <issue_description>https://github.com/sweetalert2/sweetalert2/issues/2025</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes sweetalert2/sweetalert2.github.io#120
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.