Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoogleMap component code cleanup #847

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion blazorbootstrap/Components/Maps/GoogleMap.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
Source="@GoogleMapsJsFileUrl"
OnLoad="OnScriptLoad" />

<div @ref="@Element" id="@Id" class="@ClassNames" style="@StyleNames" role="alert" @attributes="@AdditionalAttributes">
<div @ref="@Element" id="@Id" class="@ClassNames" style="@StyleNames" @attributes="@AdditionalAttributes">
</div>
16 changes: 14 additions & 2 deletions blazorbootstrap/Components/ScriptLoader/ScriptLoader.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public partial class ScriptLoader : BlazorBootstrapComponentBase
/// <summary>
/// The default content type for scripts.
/// </summary>
private const string type = "text/javascript";
private const string ScriptType = "text/javascript";

/// <summary>
/// A reference to this component instance for use in JavaScript calls.
Expand All @@ -24,7 +24,7 @@ public partial class ScriptLoader : BlazorBootstrapComponentBase
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.scriptLoader.initialize", Id, Async, Defer, ScriptId, Source, type, objRef);
await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.scriptLoader.initialize", Id, Async, Defer, ScriptId, Source, ScriptType, objRef);

await base.OnAfterRenderAsync(firstRender);
}
Expand Down Expand Up @@ -72,13 +72,19 @@ public void OnLoadJS()
/// <summary>
/// Gets or sets a value indicating whether the script should be loaded asynchronously.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
[Parameter]
public bool Async { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the script is meant to be executed
/// after the document has been parsed, but before firing DOMContentLoaded event..
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
[Parameter]
public bool Defer { get; set; }

Expand All @@ -97,12 +103,18 @@ public void OnLoadJS()
/// <summary>
/// Gets or sets the ID of the script element.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
public string? ScriptId { get; set; }

/// <summary>
/// Gets or sets the URI of the external script to load.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[Parameter]
[EditorRequired]
public string? Source { get; set; } = default!;
Expand Down
2 changes: 1 addition & 1 deletion blazorbootstrap/wwwroot/blazor.bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ window.blazorBootstrap = {
return window.blazorBootstrap.googlemaps.instances[elementId];
},
initialize: (elementId, zoom, center, markers, clickable, dotNetHelper) => {
window.blazorBootstrap.googlemaps.markerEls[elementId] = window.blazorBootstrap.googlemaps.markerEls[elementId] ?? []
window.blazorBootstrap.googlemaps.markerEls[elementId] = window.blazorBootstrap.googlemaps.markerEls[elementId] ?? [];

let mapOptions = { center: center, zoom: zoom, mapId: elementId };
let map = new google.maps.Map(document.getElementById(elementId), mapOptions);
Expand Down
Loading