Posts

MapBlazor: Architecture of a Blazor Component Library for ArcGIS Maps (Series)

MapBlazor is a Razor Class Library that puts the ArcGIS Maps SDK for JavaScript (Esri) behind a typed .NET API. A Blazor app, whether Server, WebAssembly or Auto, can add 2D maps and 3D scenes, layers, basemaps, drawing, selection, popups and widgets without writing JavaScript. This series covers the architecture behind it: how the JavaScript SDK is bundled and shipped, how the SDK is bootstrapped, how .NET and JS talk to each other, how map state flows back into Blazor, and how it is packaged and tested. Part Topic 01 Goals, project layout and the build pipeline 02 Configuration-first SDK bootstrapping and pluggable authentication (bring your own IdP) 03 The .NET ↔ JavaScript bridge: registry, DTOs, callbacks, disposal 04 The MapView<TMap> component and per-map services 05 Layers, basemaps, 2D/3D, drawing, selection, popups and widgets 06 State with Fluxor, error contracts, packaging and testing Stack: .NET 10 Razor Class Library, ArcGIS Map...

MapBlazor Architecture, Part 6: Fluxor State, Errors, Packaging and Testing

State The library publishes what happens on a map as Fluxor state and actions : [FeatureState] public sealed record MapViewState(ImmutableDictionary<string, MapState> Maps) { public MapViewState() : this(ImmutableDictionary<string, MapState>.Empty) { } } public sealed record MapState(Extent? Extent, double Zoom, double Scale, string Basemap, ViewType ViewType, bool IsBusy, MapPoint? LastClick); State is keyed by map id , so the same feature serves every map on the page. Layer state (which layers, visible, opacity, load status) is also per map . A single global layer list mixes maps up. Actions are generic over the map: MapExtentChanged<TMap> , MapClicked<TMap> , LayerAdded<TMap> , DrawCompleted<TMap> , PopupActionTriggered<TMap> , TokenExpired . Consumers choose a style: @inject IState<MapViewState> MapState // render from state ... SubscribeToAction<MapClicked<DetailMap>...

MapBlazor Architecture, Part 5: Layers, 2D/3D, Drawing, Selection and Widgets

Layers The public model has one record per SDK layer type: Record SDK class Notes FeatureLayer FeatureLayer From a URL, or client-side from graphics with a fields schema ( source ) MapImageLayer MapImageLayer Sublayer ids for selection ImageryLayer ImageryLayer WmsLayer / WfsLayer WMSLayer / WFSLayer OGC services GraphicsLayer GraphicsLayer Scratch graphics: highlights, measurements, buffers SceneLayer SceneLayer , BuildingSceneLayer , IntegratedMeshLayer , PointCloudLayer , VoxelLayer 3D only, chosen by a Kind enum await Layers.AddAsync(new FeatureLayer("parcels", new Uri("https://services.arcgis.com/.../FeatureServer/0"), Popup: new PopupTemplate("{ADDRESS}", "Owner: {OWNER}"), Index: 2)); Ordering: each map keeps an ordered list of layer ids. Index places a layer in it, and the list survives view rebuilds. Opacity is a 0–1 double in the public API, the same as the SDK. Don't i...

MapBlazor Architecture, Part 4: The MapView Component and Per-Map Services

Maps are types Each map on a page is a small marker type: public interface IMapType { static abstract string MapId { get; } // also the DOM container id static virtual bool TrackBusy => true; static virtual bool TrackExtent => true; } public sealed class OverviewMap : IMapType { public static string MapId => "overview"; } public sealed class DetailMap : IMapType { public static string MapId => "detail"; } Every service is generic over the map type. The compiler then stops you from zooming the wrong map: @inject IMapLayers<DetailMap> Layers @inject IMapZoom<DetailMap> Zoom Registration builder.Services.AddMapBlazor(o => { o.AssetsPath = new Uri(builder.HostEnvironment.BaseAddress + "_content/MapBlazor/assets"); o.ApiKey = builder.Configuration["ArcGIS:ApiKey"]; }); builder.Services.AddFluxor(f => f.ScanAssemblies(typeof(MapBlazorMarker).Assembly, typeof(Program).Assembly)); AddMa...

MapBlazor Architecture, Part 3: The .NET to JavaScript Interop Bridge

Who owns what JavaScript (browser) .NET (Blazor) invoke(mapId, dto) events Services send intentions Fluxor state summaries: extent, zoom, busy, layers Callback modules DotNetObjectReference Facade functions Registry maps · views · layers · handles ArcGIS SDK objects JavaScript owns every live SDK object. .NET never holds a reference to a MapView , Layer or Graphic . It refers to them by string ids (map id, layer id), and JS looks them up in a registry. Why not IJSObjectReference for each SDK object? SDK objects are deep and cyclic, so they can't be serialized and must stay in JS anyway. In Blazor Server, every object reference is per-circuit state that must be disposed. Thousands of graphics would mean thousands of handles. Recreating a view (for example a 2D↔3D switch, Part 5) would invalidate every reference .NET holds. Ids survive. The registry // utils/registry.ts export interface MapEntry { element: HTMLElement; // <arcgis-ma...