BlazorGoogleMaps

repository·master·Indexed 18 days ago

https://github.com/rungwiroon/blazorgooglemaps

A Blazor interop library for the Google Maps JavaScript API, version 1.0.0. It enables the integration of interactive and static maps into Blazor WebAssembly and Server applications. Key features include the <GoogleMap> component for standard maps, <AdvancedGoogleMap> and <MarkerComponent> for rendering Blazor components as markers, and <StaticMap> for lightweight image-based maps. The library supports marker clustering, custom API key configuration, and static map markers and paths.

Tokens
3.7K
Snippets
17
Records
17
Agent score
60%

What's inside BlazorGoogleMaps

  1. Use Open Iconic's SVG Sprite

    master

    The SVG sprite allows you to load all icons in a single request. To use an icon, reference the open-iconic.svg file followed by a hash and the icon name inside a <use> tag within an <svg> element.

    Styling Tips:

    • Sizing: Set equal width and height on the <svg> tag. All icons are square.
    • Coloring: Use the CSS fill property on the <use> tag to change the icon color.
    • Best Practice: Add a general class to the <svg> tag for shared styles and a unique class to the <use> tag for icon-specific styling.
    <svg class="icon">
      <use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use>
    </svg>
  2. Configure BlazorGoogleMaps API Key

    master

    Register the library in your Program.cs file. You can use simple configuration, advanced options for specific libraries/versions, or a custom key service for asynchronous loading.

    // Option 1: Simple Configuration (Recommended)
    builder.Services.AddBlazorGoogleMaps("YOUR_GOOGLE_API_KEY");
    
    // Option 2: Advanced Configuration
    builder.Services.AddBlazorGoogleMaps(new GoogleMapsComponents.Maps.MapApiLoadOptions("YOUR_GOOGLE_API_KEY")
    {
    	Version = "beta",
    	Libraries = "places,visualization,drawing,marker"
    });
    
    // Option 3: Custom Key Service (e.g., for async loading)
    builder.Services.AddScoped<IBlazorGoogleMapsKeyService, YourCustomKeyService>();
  3. Use Open Iconic SVG Sprites

    master

    The SVG sprite allows you to load all icons in a single request. To use an icon, reference the sprite file and the specific icon ID within a <use> tag inside an <svg> element.

    Styling Tips:

    • Sizing: Set equal width and height on the <svg> tag.
    • Coloring: Use the CSS fill property on the <use> tag to change the icon color.
    • Best Practice: Add a general class to the <svg> tag for shared styles and a unique class to the <use> tag for icon-specific styling.
    <svg class="icon">
      <use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use>
    </svg>
    
    <style>
    .icon {
      width: 16px;
      height: 16px;
    }
    
    .icon-account-login {
      fill: #f00;
    }
    </style>