Skip to content

Enhance Google Map demo, script loading, and marker customization#1292

Merged
gvreddy04 merged 3 commits into
mainfrom
bugfix/1287-issue-adding-multiple-google-map-components-to-same-page
Jul 10, 2026
Merged

Enhance Google Map demo, script loading, and marker customization#1292
gvreddy04 merged 3 commits into
mainfrom
bugfix/1287-issue-adding-multiple-google-map-components-to-same-page

Conversation

@gvreddy04

Copy link
Copy Markdown
Contributor

This pull request introduces significant enhancements and refactoring to the Google Maps marker customization features in the BlazorBootstrap library and its demo components. The main focus is on expanding marker glyph options (supporting text, image, and legacy icon fonts), improving the marker rendering pipeline, and updating demos and documentation to reflect the new capabilities. Additionally, the Google Maps script loading and initialization logic has been improved for reliability and clarity.

Key changes include:

Marker Customization Enhancements

  • Added new properties to the PinElement model: GlyphText (for text glyphs), GlyphSrc (for image glyphs), and additional styling options (Background, BorderColor, GlyphColor, Scale). The legacy Glyph property is now marked as obsolete, and UseIconFonts is retained for backward compatibility.
  • Updated the marker rendering logic in blazor.bootstrap.js to support the new glyph options, including rendering text and image glyphs, and improved the handling of icon fonts.

Demo and Documentation Updates

  • Updated demo pages and documentation to use the new PinElement.GlyphText and PinElement.GlyphSrc properties, and added new demo sections for text and image glyphs.
  • Added #pragma warning disable/restore CS0618 in demos that intentionally use the legacy icon-font path for clarity and to suppress warnings.

Google Maps Initialization Improvements

  • Refactored the script loading and initialization process: the Google Maps JS API is now loaded with async and a named callback, and initialization is deferred until the API is ready. Pending initializations are handled robustly via a new onApiLoaded callback and pendingInitializations queue.

Demo Layout Improvements

  • Improved the layout of the main examples demo to display two maps side by side using Bootstrap grid classes.

These changes modernize the marker customization API, provide a smoother developer experience, and ensure backward compatibility for existing applications.

Updated `GoogleMap_Demo_01_Examples.razor` to display two maps side-by-side using a responsive Bootstrap grid. Modified `GoogleMap.razor` to use a fixed `ScriptId` for consistent script handling.

Improved `blazor.bootstrap.js` to handle existing scripts with the same `ScriptId`, invoking appropriate callbacks (`OnLoadJS` or `OnErrorJS`) based on the script's loading status. Added dataset attributes to track script loading state and ensure proper event handling.
Updated marker customization options to include `GlyphText` for text glyphs and `GlyphSrc` for image glyphs. Deprecated the legacy `Glyph` property while maintaining backward compatibility.

Enhanced `GoogleMap.razor` and `blazor.bootstrap.js` to support asynchronous Google Maps API loading and streamlined marker rendering.

Added new demos for text and image glyphs, updated documentation, and introduced new properties in `PinElement.cs` for better marker customization.
@gvreddy04 gvreddy04 added this to the 4.0.0 milestone Jul 10, 2026
@gvreddy04 gvreddy04 self-assigned this Jul 10, 2026
Added a check to ensure the DOM element exists before map initialization to prevent runtime errors. Introduced a reusable `element` variable to avoid redundant DOM queries. Updated marker elements initialization with a nullish coalescing operator for better fallback handling.
@gvreddy04 gvreddy04 linked an issue Jul 10, 2026 that may be closed by this pull request
@gvreddy04 gvreddy04 merged commit 9a3c40f into main Jul 10, 2026
1 of 3 checks passed
@gvreddy04 gvreddy04 deleted the bugfix/1287-issue-adding-multiple-google-map-components-to-same-page branch July 10, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue Adding multiple Google Map components to same page

1 participant