![]() |
VOOZH | about |
dotnet add package BlazorGoogleMaps --version 4.15.2
NuGet\Install-Package BlazorGoogleMaps -Version 4.15.2
<PackageReference Include="BlazorGoogleMaps" Version="4.15.2" />
<PackageVersion Include="BlazorGoogleMaps" Version="4.15.2" />Directory.Packages.props
<PackageReference Include="BlazorGoogleMaps" />Project file
paket add BlazorGoogleMaps --version 4.15.2
#r "nuget: BlazorGoogleMaps, 4.15.2"
#:package BlazorGoogleMaps@4.15.2
#addin nuget:?package=BlazorGoogleMaps&version=4.15.2Install as a Cake Addin
#tool nuget:?package=BlazorGoogleMaps&version=4.15.2Install as a Cake Tool
🗺️ Blazor interop for Google Maps JavaScript API
👁 NuGet version (BlazorGoogleMaps)
👁 .NET 10
A powerful and easy-to-use Blazor library for integrating Google Maps into your Blazor WebAssembly and Blazor Server applications.
Install the package via NuGet Package Manager:
dotnet add package BlazorGoogleMaps
Or via NuGet Package Manager Console:
Install-Package BlazorGoogleMaps
Add BlazorGoogleMaps to your Program.cs:
builder.Services.AddBlazorGoogleMaps("YOUR_GOOGLE_API_KEY");
builder.Services.AddBlazorGoogleMaps(new GoogleMapsComponents.Maps.MapApiLoadOptions("YOUR_GOOGLE_API_KEY")
{
Version = "beta",
Libraries = "places,visualization,drawing,marker"
});
For more complex scenarios (e.g., loading keys asynchronously from a database):
builder.Services.AddScoped<IBlazorGoogleMapsKeyService, YourCustomKeyService>();
⚠️ Legacy Method (Not Recommended): Adding the script tag directly to your HTML is still supported but not recommended.
Add the required JavaScript files to your wwwroot/index.html (Blazor WASM) or _Host.cshtml/_HostLayout.cshtml (Blazor Server):
<script src="_content/BlazorGoogleMaps/js/objectManager.js"></script>
Optional: For marker clustering support, add:
<script src="https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js"></script>
Create a simple map component:
@page "/map"
@using GoogleMapsComponents
@using GoogleMapsComponents.Maps
<h1>Google Map</h1>
<div style="height: 500px;">
<GoogleMap @ref="@_map1"
Id="map1"
Options="@_mapOptions"
Height="100%"
OnAfterInit="@AfterMapRender">
</GoogleMap>
</div>
@code {
private GoogleMap? _map1;
private MapOptions _mapOptions = default!;
protected override void OnInitialized()
{
_mapOptions = new MapOptions()
{
Zoom = 13,
Center = new LatLngLiteral()
{
Lat = 13.505892,
Lng = 100.8162
},
MapTypeId = MapTypeId.Roadmap
};
}
private async Task AfterMapRender()
{
// Map is ready - you can perform additional initialization here
var bounds = await LatLngBounds.CreateAsync(_map1!.JsRuntime);
}
}
Render interactive Blazor components as markers (requires Google Maps v=beta and a MapId):
@page "/advanced-map"
@using GoogleMapsComponents
@using GoogleMapsComponents.Maps
<h1>Advanced Map with Blazor Markers</h1>
<AdvancedGoogleMap @ref="@_map1" Id="map1" Options="@_mapOptions">
@foreach (var marker in Markers)
{
<MarkerComponent
@key="marker.Id"
Lat="@marker.Lat"
Lng="@marker.Lng"
Clickable="@marker.Clickable"
Draggable="@marker.Draggable"
OnClick="@(() => marker.Active = !marker.Active)"
OnMove="@(pos => marker.UpdatePosition(pos))">
<div class="custom-marker">
<h4>@marker.Title</h4>
<p>Custom Blazor Content</p>
</div>
</MarkerComponent>
}
</AdvancedGoogleMap>
@code {
private AdvancedGoogleMap? _map1;
private List<MarkerData> Markers =
[
new MarkerData { Id = 1, Lat = 13.505892, Lng = 100.8162, Title = "Location 1" }
];
private MapOptions _mapOptions = new()
{
Zoom = 13,
Center = new LatLngLiteral()
{
Lat = 13.505892,
Lng = 100.8162
},
MapId = "DEMO_MAP_ID", // Required for advanced markers
MapTypeId = MapTypeId.Roadmap
};
public class MarkerData
{
public int Id { get; set; }
public string Title { get; set; } = string.Empty;
public double Lat { get; set; }
public double Lng { get; set; }
public bool Clickable { get; set; } = true;
public bool Draggable { get; set; }
public bool Active { get; set; }
public void UpdatePosition(LatLngLiteral position)
{
Lat = position.Lat;
Lng = position.Lng;
}
}
}
Explore interactive examples and learn more features:
The server-side demos include the most up-to-date examples covering:
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License.
Happy Mapping! 🗺️
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on BlazorGoogleMaps:
| Package | Downloads |
|---|---|
|
templar-common-libary
Package Description |
|
|
Magiq.Blazor
Provides views and services to be used in Blazor Client and Server projects. |
|
|
Biss.Maps.Blazor
Biss Core SDK |
|
|
AeroBlazor
A blazor library, extending MudBlazor |
|
|
Microfrontend.one
Package Description |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.15.2 | 358 | 6/13/2026 |
| 4.15.1 | 25,822 | 2/23/2026 |
| 4.15.0 | 4,489 | 1/27/2026 |
| 4.14.1 | 17,468 | 12/22/2025 |
| 4.14.0 | 3,776 | 11/27/2025 |
| 4.13.8 | 3,159 | 11/18/2025 |
| 4.13.7 | 6,392 | 10/27/2025 |
| 4.13.6 | 22,399 | 8/5/2025 |
| 4.13.5 | 1,247 | 7/30/2025 |
| 4.13.4 | 3,716 | 7/27/2025 |
| 4.13.3 | 386 | 7/26/2025 |
| 4.13.2 | 1,500 | 7/15/2025 |
| 4.13.1 | 2,571 | 7/5/2025 |
| 4.13.0 | 5,078 | 6/5/2025 |
| 4.12.2 | 3,232 | 6/2/2025 |
| 4.12.1 | 490 | 6/1/2025 |
| 4.12.0 | 605 | 5/28/2025 |
| 4.11.3 | 302 | 5/28/2025 |
| 4.11.2 | 2,540 | 5/13/2025 |
| 4.11.1 | 24,118 | 4/20/2025 |