Skip to content
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1c01bc3
add BitMap component #10110
msynk May 18, 2026
3f0880d
resolve review comments
msynk May 18, 2026
478dcbf
resolve review comments II
msynk May 18, 2026
3454a53
resolve review comments II
msynk May 19, 2026
7931795
resolve review comments III
msynk May 20, 2026
ff02e84
resolve review comments V
msynk May 20, 2026
b79069b
resolve review comments VI
msynk May 23, 2026
bf9d3b1
resolve review comments VII
msynk May 24, 2026
3e5b401
resolve review comments VIII
msynk May 24, 2026
dc14dbb
resolve review comments IX
msynk May 24, 2026
1776a3f
resolve review comments X
msynk May 24, 2026
77a0b9b
resolve review comments XI
msynk May 25, 2026
60e697a
resolve review comments XII
msynk May 25, 2026
206411c
resolve review comments XIII
msynk May 25, 2026
7006eb6
resolve review comments XIV
msynk May 25, 2026
225538f
resolve review comments XV
msynk May 25, 2026
3cbb988
resolve review comments XVI
msynk May 25, 2026
c075067
resolve review comments XVII
msynk May 25, 2026
e63ad39
resolve review comments XVIII
msynk May 25, 2026
f0c26dd
resolve review comments XIX
msynk May 25, 2026
997c2a1
resolve review comments XX
msynk May 25, 2026
0d473e8
resolve review comments XXI
msynk May 26, 2026
7ce7be8
resovle review comments XXII
msynk May 26, 2026
f71637b
resolve review comments XXIII
msynk May 27, 2026
94be3f0
resolve review comments XXIV
msynk May 27, 2026
aba18f5
resolve local review findings
msynk May 27, 2026
708c184
resolve review comments XXV
msynk May 27, 2026
523041d
resolve review comments XXVI
msynk May 28, 2026
b68b140
code formatting on demo page
msynk May 28, 2026
c41d99f
resolve review comments XXVII
msynk May 28, 2026
e426258
resolve review comments XXVIII
msynk May 29, 2026
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ ModelManifest.xml
# Rider
.idea

#kiro
.kiro

#cursor
.cursor

profile.arm.json

# bit
Expand All @@ -243,6 +249,7 @@ _book
/src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/scripts/*.js
/src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/**/*.css.gz
!/src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/quilljs/*.css
!/src/BlazorUI/Bit.BlazorUI.Extras/wwwroot/leaflet/*.css

/src/BlazorUI/Bit.BlazorUI.Assets/**/*.css
/src/BlazorUI/Bit.BlazorUI.Assets/wwwroot/scripts/*.js
Expand Down
21 changes: 21 additions & 0 deletions src/BlazorUI/Bit.BlazorUI.Extras/Components/Map/BitMap.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@namespace Bit.BlazorUI
@inherits BitComponentBase
@typeparam TMapProvider where TMapProvider : class, IBitMapProvider, new()

<div @ref="RootElement"
@attributes="HtmlAttributes"
id="@_Id"
style="@StyleBuilder.Value"
class="@ClassBuilder.Value"
dir="@Dir?.ToString().ToLowerInvariant()">
<div id="@_canvasId"
@ref="_mapElement"
class="bit-map-canvas"
tabindex="0"
role="region"
aria-label="@(AriaLabel ?? "Map")"></div>
@if (ChildContent is not null)
{
<div class="bit-map-overlay">@ChildContent</div>
}
</div>
966 changes: 966 additions & 0 deletions src/BlazorUI/Bit.BlazorUI.Extras/Components/Map/BitMap.razor.cs

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions src/BlazorUI/Bit.BlazorUI.Extras/Components/Map/BitMap.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
.bit-map {
width: 100%;
height: 100%;
box-sizing: border-box;
position: relative;
overflow: hidden;
}

.bit-map-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}

.bit-map-canvas:focus-visible {
outline: 2px solid Highlight;
outline: 2px solid -webkit-focus-ring-color;
outline-offset: -2px;
}

.bit-map-overlay {
position: absolute;
inset: 0;
pointer-events: none;
z-index: 1;

> * {
pointer-events: auto;
}
}

// OpenLayers popup. Styles live here (instead of inline cssText in the TS provider)
// so they aren't blocked under strict CSP configurations that disallow inline styles
// and so consumers can theme them from their own stylesheets.
.bit-map-ol-popup {
position: relative;
max-width: 280px;
padding: 10px 12px;
background: #fff;
border-radius: 6px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
overflow-wrap: break-word;
}

.bit-map-ol-popup--hidden {
display: none;
}

.bit-map-ol-popup__close {
position: absolute;
top: 2px;
right: 6px;
padding: 2px 4px;
border: none;
background: transparent;
color: #666;
font-size: 16px;
line-height: 1;
cursor: pointer;
}

.bit-map-ol-popup__content {
margin-top: 4px;
}
Comment thread
msynk marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace Bit.BlazorUI;

/// <summary>
/// Source of a <see cref="BitMap{TMapProvider}.OnInteropError"/> event.
/// </summary>
public enum BitMapInteropErrorSource
{
/// <summary>Loading the provider's external scripts failed.</summary>
ScriptLoad,

/// <summary>Loading the provider's external stylesheets failed.</summary>
StylesheetLoad,

/// <summary>The provider's <c>init</c> JS call failed.</summary>
Init,

/// <summary>The provider's <c>sync</c> JS call failed.</summary>
Sync,

/// <summary>The provider's <c>dispose</c> JS call failed.</summary>
Dispose,

/// <summary>An imperative call (add/remove/update) into the provider failed.</summary>
Imperative,

/// <summary>A consumer-supplied event handler threw while processing a JS-invoked callback.</summary>
Callback,
}

/// <summary>
/// Payload for <see cref="BitMap{TMapProvider}.OnInteropError"/>. Carries the underlying
/// exception and a tag indicating which interop call site produced it.
/// </summary>
public sealed class BitMapInteropErrorArgs
{
/// <summary>Where the error originated.</summary>
public required BitMapInteropErrorSource Source { get; init; }

/// <summary>The exception that was caught.</summary>
public required Exception Exception { get; init; }

/// <summary>Optional context (e.g. method name, marker id) for diagnostics.</summary>
public string? Context { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
namespace Bit.BlazorUI;

/// <summary>
/// Provider-agnostic JS runtime helpers for <see cref="BitMap{TMapProvider}"/>.
/// All calls go through <c>BitBlazorUI.&lt;JsObjectName&gt;.&lt;method&gt;</c> so each
/// provider exposes its own implementation under the same shape.
/// </summary>
internal static class BitMapJsRuntimeExtensions
{
public static ValueTask BitMapInit<TProvider>(this IJSRuntime jsRuntime,
string jsObjectName,
string id,
string canvasId,
ElementReference element,
DotNetObjectReference<BitMap<TProvider>>? dotnetObj,
object options)
where TProvider : class, IBitMapProvider, new()
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.init", id, canvasId, element, dotnetObj, options);
}

public static ValueTask BitMapSync(this IJSRuntime jsRuntime, string jsObjectName, string id, object options)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.sync", id, options);
}

public static ValueTask BitMapDispose(this IJSRuntime jsRuntime, string jsObjectName, string id)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.dispose", id);
}

public static ValueTask BitMapInvalidateSize(this IJSRuntime jsRuntime, string jsObjectName, string id)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.invalidateSize", id);
}

public static ValueTask<System.Text.Json.JsonElement> BitMapGetView(this IJSRuntime jsRuntime, string jsObjectName, string id)
{
return jsRuntime.Invoke<System.Text.Json.JsonElement>($"BitBlazorUI.{jsObjectName}.getView", id);
}

public static ValueTask BitMapSetView(this IJSRuntime jsRuntime, string jsObjectName, string id,
double lat, double lng, double? zoom, bool animate)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.setView", id, lat, lng, zoom, animate);
}

public static ValueTask BitMapFlyTo(this IJSRuntime jsRuntime, string jsObjectName, string id,
double lat, double lng, double? zoom)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.flyTo", id, lat, lng, zoom);
}

public static ValueTask BitMapFitBounds(this IJSRuntime jsRuntime, string jsObjectName, string id,
double swLat, double swLng,
double neLat, double neLng,
int paddingPixels)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.fitBounds", id, swLat, swLng, neLat, neLng, paddingPixels);
}

public static ValueTask BitMapFitBoundsToMarkers(this IJSRuntime jsRuntime, string jsObjectName, string id, int paddingPixels)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.fitBoundsToMarkers", id, paddingPixels);
}

public static ValueTask BitMapAddMarker(this IJSRuntime jsRuntime, string jsObjectName, string id, string markerId, object marker)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addMarker", id, markerId, marker);
}

public static ValueTask BitMapRemoveMarker(this IJSRuntime jsRuntime, string jsObjectName, string id, string markerId)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.removeMarker", id, markerId);
}

public static ValueTask BitMapClearMarkers(this IJSRuntime jsRuntime, string jsObjectName, string id)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.clearMarkers", id);
}

public static ValueTask BitMapSyncMarkers(this IJSRuntime jsRuntime, string jsObjectName, string id, string[] markerIds, object[] markers)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.syncMarkers", id, markerIds, markers);
}

public static ValueTask BitMapSetMarkerPosition(this IJSRuntime jsRuntime, string jsObjectName, string id,
string markerId, double lat, double lng)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.setMarkerPosition", id, markerId, lat, lng);
}

public static ValueTask BitMapOpenMarkerPopup(this IJSRuntime jsRuntime, string jsObjectName, string id, string markerId)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.openMarkerPopup", id, markerId);
}

public static ValueTask BitMapAddPolyline(this IJSRuntime jsRuntime, string jsObjectName, string id,
string layerId, object[] path, object? style)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addPolyline", id, layerId, path, style);
}

public static ValueTask BitMapAddPolygon(this IJSRuntime jsRuntime, string jsObjectName, string id,
string layerId, object[] ring, object? style)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addPolygon", id, layerId, ring, style);
}

public static ValueTask BitMapAddCircle(this IJSRuntime jsRuntime, string jsObjectName, string id,
string layerId, double lat, double lng, double radiusMeters, object? style)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addCircle", id, layerId, lat, lng, radiusMeters, style);
}

public static ValueTask BitMapAddRectangle(this IJSRuntime jsRuntime, string jsObjectName, string id,
string layerId, double swLat, double swLng,
double neLat, double neLng, object? style)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addRectangle", id, layerId, swLat, swLng, neLat, neLng, style);
}

public static ValueTask BitMapAddGeoJson(this IJSRuntime jsRuntime, string jsObjectName, string id,
string layerId, string geoJson, object? style)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addGeoJson", id, layerId, geoJson, style);
}

public static ValueTask BitMapRemoveLayer(this IJSRuntime jsRuntime, string jsObjectName, string id, string layerId)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.removeLayer", id, layerId);
}

public static ValueTask BitMapClearVectorLayers(this IJSRuntime jsRuntime, string jsObjectName, string id)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.clearVectorLayers", id);
}

public static ValueTask BitMapAddTileOverlay(this IJSRuntime jsRuntime, string jsObjectName, string id, object overlay)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.addTileOverlay", id, overlay);
}

public static ValueTask BitMapRemoveTileOverlay(this IJSRuntime jsRuntime, string jsObjectName, string id, string overlayId)
{
return jsRuntime.InvokeVoid($"BitBlazorUI.{jsObjectName}.removeTileOverlay", id, overlayId);
}
}
72 changes: 72 additions & 0 deletions src/BlazorUI/Bit.BlazorUI.Extras/Components/Map/BitMapLatLng.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
namespace Bit.BlazorUI;

/// <summary>
/// Geographic coordinate in WGS84 (EPSG:4326).
/// </summary>
public readonly record struct BitMapLatLng
{
private readonly double _latitude;
private readonly double _longitude;

/// <summary>
/// Creates a new <see cref="BitMapLatLng"/> with the given coordinates.
/// </summary>
/// <param name="latitude">Latitude in degrees. Must be within [-90, 90].</param>
/// <param name="longitude">Longitude in degrees. Must be within [-180, 180].</param>
/// <exception cref="ArgumentOutOfRangeException">Thrown when either value is outside its valid range or NaN.</exception>
public BitMapLatLng(double latitude, double longitude)
{
_latitude = ValidateLatitude(latitude);
_longitude = ValidateLongitude(longitude);
}

/// <summary>
/// Latitude in degrees. Must be within [-90, 90].
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the value is outside the valid range.</exception>
public double Latitude
{
get => _latitude;
init => _latitude = ValidateLatitude(value);
}
Comment thread
msynk marked this conversation as resolved.
Comment thread
msynk marked this conversation as resolved.
Comment thread
msynk marked this conversation as resolved.

/// <summary>
/// Longitude in degrees. Must be within [-180, 180].
/// </summary>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the value is outside the valid range.</exception>
public double Longitude
{
get => _longitude;
init => _longitude = ValidateLongitude(value);
}
Comment thread
msynk marked this conversation as resolved.
Comment thread
msynk marked this conversation as resolved.
Comment thread
msynk marked this conversation as resolved.
Comment thread
msynk marked this conversation as resolved.

/// <summary>Shorthand for <see cref="Latitude"/>.</summary>
public double Lat => Latitude;

/// <summary>Shorthand for <see cref="Longitude"/>.</summary>
public double Lng => Longitude;

private static double ValidateLatitude(double value)
{
if (double.IsNaN(value) || value < -90 || value > 90)
{
throw new ArgumentOutOfRangeException(
nameof(Latitude),
value,
$"{nameof(BitMapLatLng)}.{nameof(Latitude)} must be a number between -90 and 90 (inclusive).");
}
return value;
}

private static double ValidateLongitude(double value)
{
if (double.IsNaN(value) || value < -180 || value > 180)
{
throw new ArgumentOutOfRangeException(
nameof(Longitude),
value,
$"{nameof(BitMapLatLng)}.{nameof(Longitude)} must be a number between -180 and 180 (inclusive).");
}
return value;
}
}
Loading
Loading