BlazorGoogleMaps 4.7.11

There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorGoogleMaps --version 4.7.11                
NuGet\Install-Package BlazorGoogleMaps -Version 4.7.11                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorGoogleMaps" Version="4.7.11" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorGoogleMaps --version 4.7.11                
#r "nuget: BlazorGoogleMaps, 4.7.11"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorGoogleMaps as a Cake Addin
#addin nuget:?package=BlazorGoogleMaps&version=4.7.11

// Install BlazorGoogleMaps as a Cake Tool
#tool nuget:?package=BlazorGoogleMaps&version=4.7.11                

BlazorGoogleMaps

Blazor interop for GoogleMap library

NuGet version (BlazorGoogleMaps)

Usage

  1. Provide your Google API key to BlazorGoogleMaps with one of the following methods. (You can get a key here: https://developers.google.com/maps/documentation/javascript/get-api-key)

Use the bootstrap loader with a key service (recommended):

services.AddBlazorGoogleMaps("YOUR_KEY_GOES_HERE");

OR specify google api libraries and/or version:

services.AddBlazorGoogleMaps(new GoogleMapsComponents.Map.MapApiLoadOptions("YOUR_KEY_GOES_HERE")
    {
        Version = "beta",
        Libraries = "places,visualization,drawing,marker",
    });

OR to do something more complex (e.g. looking up keys asynchronously), implement a Scoped key service and add it with something like:

services.AddScoped<IBlazorGoogleMapsKeyService, YourServiceImplementation>();

OR (legacy - not recommended) Add google map script HEAD tag to wwwroot/index.html in Client side or _Host.cshtml in Server Side.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_GOES_HERE&v=3"></script>
  1. Add path to project javascript functions file in wwwroot/index.html for Blazor WASM, or in _Host.cshtml or _HostLayout.cshtml for Blazor Server.
<script src="_content/BlazorGoogleMaps/js/objectManager.js"></script>

If you want to use marker clustering add this script as well:

<script src="https://unpkg.com/@@googlemaps/markerclusterer/dist/index.min.js"></script>
  1. Using the component is the same for both Blazor WASM and Blazor Server
@page "/map"
@using GoogleMapsComponents
@using GoogleMapsComponents.Maps

<h1>Google Map</h1>
<div style="height:@Height">
<GoogleMap @ref="@_map1" Id="map1" Options="@mapOptions" Height="100%" OnAfterInit="AfterMapRender"></GoogleMap>
</div>
@functions {
	private GoogleMap _map1;
	private MapOptions mapOptions;	

	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()
	 {
	     _bounds = await LatLngBounds.CreateAsync(_map1.JsRuntime);
	 }		
}

Samples

Please check server side samples https://github.com/rungwiroon/BlazorGoogleMaps/tree/master/ServerSideDemo which are most to date

ClientSide demos online https://rungwiroon.github.io/BlazorGoogleMaps/mapEvents

Breaking change from 4.0.0 Migrate to .NET 8 #286.

Breaking change from 3.0.0 Migrate from Newtonsoft.Json to System.Text.Json.

Breaking change from 2.0.0 LatLngLiteral constructor's parameters order changed #173

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.7.13 151 10/3/2024
4.7.12 595 9/29/2024
4.7.11 3,882 8/29/2024
4.7.10 161 8/28/2024
4.7.9 101 8/28/2024
4.7.8 108 8/28/2024
4.7.7 768 8/25/2024
4.7.6 3,154 8/12/2024
4.7.5 156 8/11/2024
4.7.4 122 8/10/2024
4.7.3 1,835 7/29/2024
4.7.2 785 7/25/2024
4.7.1 3,127 7/8/2024
4.7.0 272 7/4/2024
4.6.2 318 7/2/2024
4.6.1 171 7/1/2024
4.6.0 612 6/26/2024
4.5.0 834 6/22/2024
4.4.2 3,480 6/12/2024
4.4.1 227 6/11/2024
4.4.0 182 6/10/2024
4.3.0 5,500 5/15/2024
4.2.0 5,243 4/25/2024
4.1.2 7,336 3/21/2024
4.1.1 464 3/20/2024
4.1.0 20,373 2/2/2024
4.0.3 871 1/18/2024
4.0.2 4,210 12/20/2023
4.0.1 1,706 12/17/2023
4.0.0 237 12/15/2023
3.3.2 10,616 12/15/2023
3.3.1 7,013 12/5/2023
3.2.5 2,498 11/23/2023
3.2.4 168 11/23/2023
3.2.3 7,143 10/30/2023
3.2.2 1,805 10/25/2023
3.2.1 241 10/25/2023
3.2.0 4,599 9/18/2023
3.1.4 3,785 9/9/2023
3.1.3 564 9/3/2023
3.1.2 7,708 8/1/2023
3.1.1 5,163 7/19/2023
3.1.0 2,018 7/10/2023
3.0.8 265 7/9/2023
3.0.7 9,402 6/9/2023
3.0.6 6,194 5/7/2023
3.0.5 3,546 4/13/2023
3.0.4 443 4/11/2023
3.0.3 1,355 4/6/2023
3.0.2 582 4/3/2023
3.0.1 346 4/1/2023
3.0.0 1,797 3/28/2023
2.5.7 12,323 3/14/2023
2.5.6 960 3/13/2023
2.5.5 3,791 2/24/2023
2.5.4 10,091 2/11/2023
2.5.3 946 2/6/2023
2.5.2 2,776 1/20/2023
2.5.1 1,213 1/17/2023
2.4.4 9,977 12/13/2022
2.4.3 6,461 11/29/2022
2.4.2 370 11/29/2022
2.4.1 1,501 11/25/2022
2.3.1 2,758 11/14/2022
2.2.6 26,445 9/5/2022
2.2.5 1,589 8/27/2022
2.2.4 434 8/27/2022
2.2.3 1,416 8/22/2022
2.2.2 569 8/19/2022
2.2.1 24,964 6/28/2022
2.2.0 2,983 6/20/2022
2.1.1 2,428 5/23/2022
2.1.0 2,221 5/3/2022
2.0.6 718 4/30/2022
2.0.5 1,726 4/21/2022
2.0.4 1,443 4/15/2022
2.0.3 1,109 4/1/2022
2.0.2 565 3/30/2022
2.0.1 501 3/30/2022
2.0.0 1,217 3/29/2022
1.5.5 11,558 2/24/2022
1.5.4 672 2/21/2022
1.5.3 1,903 2/16/2022
1.5.2 692 2/15/2022
1.5.1 4,153 2/7/2022
1.4.2 6,949 12/15/2021
1.4.1 5,824 12/8/2021
1.4.0 373 12/7/2021
1.3.0 526 12/2/2021
1.2.1 16,074 10/11/2021
1.1.8 1,353 9/27/2021
1.1.7 530 9/25/2021
1.1.6 405 9/23/2021
1.1.5 1,244 9/16/2021
1.1.4 1,277 9/12/2021
1.1.3 565 9/9/2021
1.1.2 767 9/7/2021
1.1.1 1,304 8/30/2021
1.0.17 2,182 7/27/2021
1.0.16 832 7/17/2021
1.0.15 8,881 4/29/2021
1.0.14 5,561 4/9/2021
1.0.13 25,772 3/18/2021
1.0.12 4,386 2/13/2021
1.0.11 575 2/10/2021
1.0.10 433 2/10/2021
1.0.9 412 2/10/2021
1.0.8 774 2/3/2021
1.0.7 3,993 1/30/2021
1.0.6 488 1/28/2021
1.0.5 956 1/18/2021
1.0.4 622 1/14/2021
1.0.3 448 1/13/2021
1.0.2 1,412 1/1/2021
1.0.1 860 12/25/2020
1.0.0 464 12/25/2020
0.9.3 460 12/25/2020
0.9.2 710 12/22/2020
0.9.1 1,161 12/4/2020
0.9.0 6,904 10/23/2020
0.8.1 1,092 10/4/2020
0.8.0 1,778 9/16/2020
0.7.1 1,651 8/9/2020
0.6.14 542 8/4/2020
0.6.13 699 8/2/2020
0.6.12 723 7/28/2020
0.6.11 517 7/27/2020
0.6.10 2,669 7/20/2020
0.6.9 619 7/14/2020
0.6.8 654 7/9/2020
0.6.7 602 7/7/2020
0.6.6 670 6/30/2020
0.6.5 1,037 6/4/2020
0.6.4 1,586 5/16/2020
0.6.3 985 5/5/2020
0.6.2 1,605 4/16/2020
0.6.1 715 3/27/2020
0.6.0 525 3/27/2020
0.5.9 546 3/26/2020
0.5.8 942 3/25/2020
0.5.7 524 3/25/2020
0.5.6 632 3/17/2020
0.5.5 1,477 3/7/2020
0.5.4 889 2/9/2020
0.5.3 629 2/8/2020
0.5.2 1,821 1/24/2020
0.5.1-alpha 826 12/9/2019
0.4.8-alpha 434 12/1/2019
0.4.7-alpha 513 10/18/2019
0.4.6-alpha 469 9/26/2019
0.4.5-alpha 327 8/20/2019
0.4.0-alpha 336 6/15/2019
0.3.0 863 6/1/2019
0.1.0 929 2/2/2019