DeepWorks Studios Blazor Component Library

Demo user Administrator ยท Blazor Server Library 20261206222504-6e8ff32.dirty
This page needs an interactive render mode, so the static SSR demo does not list it. Open it in the interactive Server demo.

DwsMap

An interactive map that needs no map service: it draws the countries of the world itself (Natural Earth, 1:50m, shipped with the library) in theme colors, and can lay raster tiles of your choice underneath. Drag, pinch, Ctrl + scroll, double-click or the keyboard (arrow keys, + / -, Home) move and zoom it; markers, lines, areas and circles are drawn on top. Moving the map runs in the browser, so it stays smooth on Blazor Server, and the component hears where it came to rest. The host page loads dws.js.

API Reference

Interface-Description

Name Typ Default Description
CurrentCenter DwsGeoPoint Center Where the map is centred now, as last reported by the browser.
CurrentZoom double Zoom The zoom the map shows now, as last reported by the browser.
CurrentBounds DwsGeoBounds? null The area the map shows now; null until the browser has measured the map. Across the antimeridian SouthWest.Longitude is greater than NorthEast.Longitude.
IsBasemapLoaded bool false True once the basemap has loaded.
Name Typ Parameters Description
SetViewAsync Task DwsGeoPoint center, double zoom, bool = true animate Moves the map to a position at a zoom (clamped to MinZoom .. MaxZoom), animated unless the user prefers reduced motion.
FitBoundsAsync Task DwsGeoBounds bounds, int = 48 padding, bool = true animate Moves and zooms the map so the bounds fill it, with padding pixels to spare. Called before the map was measured, it runs once it has been.
FitContentAsync Task int = 48 padding, bool = true animate Fits every marker and shape into the map; does nothing when there are none.
ZoomInAsync Task Zooms in by one level around the middle of the map.
ZoomOutAsync Task Zooms out by one level around the middle of the map.
ResetViewAsync Task Returns to the Center and Zoom the map started with.
LocateAsync Task<DwsMapLocateStatus> Asks the browser for the user's position as the 'my position' button does and returns how it ended (Located, Denied, Unavailable, Timeout, Unsupported). Browsers answer only after a user gesture and over a secure connection.
ClearLocation void Removes the position marker and the message of a failed attempt.
StartFollowingAsync Task<bool> Starts following the position as the toggle does; false when the map is not interactive yet or the browser offers no position. The compass of iOS is only given to a press of the toggle.
StopFollowingAsync Task Stops following; the position marker stays (ClearLocation removes it). Also: properties IsFollowingPosition and LocationHeading.
AddShapePointAsync(DwsGeoPoint point, int? index = null) Task<bool> Adds a point to the edited shape, at the end or at index. False when no shape is edited or the point is not valid.
SetShapePointAsync(int index, DwsGeoPoint point) Task<bool> Moves a point of the edited shape to these coordinates.
MoveShapePointAsync(int fromIndex, int toIndex) Task<bool> Moves a point of the edited shape to another place in the order.
RemoveShapePointAsync(int index) Task<bool> Removes a point of the edited shape. The property EditedPoints returns the points as the map draws them.
Name Typ Default Description
Center DwsGeoPoint 20° N, 0° E The point in the middle of the map (Latitude, Longitude in degrees). Changing it moves the map; with @bind-Center it follows the user once the map has come to rest. An invalid position is ignored with a warning.
Zoom double 2 Zoom level: at 0 the world is 256px wide, every level doubles it; fractions are allowed. Changing it zooms the map; with @bind-Zoom it follows the user. Clamped to MinZoom .. MaxZoom.
MinZoom double 1 The smallest zoom the user can reach, 0 .. 22.
MaxZoom double 18 The largest zoom the user can reach, MinZoom .. 22. An invalid range is corrected with a warning.
Width int? null Width in px. Null fills the width of the container.
Height int? null Height in px. Null uses 400px.
AriaLabel string? null Accessible name of the map. Null uses the localized "Interactive map".
ShowBasemap bool true Draws the countries of the world (Natural Earth, 1:50m). The data (about 290 KB compressed) loads once per page, the first time a map needs it; a message shows while it loads or when it fails.
BasemapUrl string? null Where to load the basemap from. Null uses data/dws-map-world.json shipped with the library, next to dws.js.
CountryColors IReadOnlyDictionary<string, DwsColor>? null Fill colors of countries by ISO 3166-1 alpha-3 code (e.g. "DEU"), for a choropleth. Pass a new dictionary to change them.
InteractiveCountries bool false Countries highlight under the pointer, show their name in the current language and raise OnCountryClick.
TileUrlTemplate string? null URL of raster tiles drawn under the basemap, with {z}, {x} and {y}. The countries then only show their CountryColors. Nothing is loaded from a tile server unless this is set.
TileAttribution string? null Attribution the tile provider requires, shown in the corner as plain text.
TileMinZoom int 0 The lowest zoom level the tile server has.
TileMaxZoom int 19 The highest zoom level the tile server has; deeper zooms scale its tiles up.
Markers IEnumerable<DwsMapMarker>? null The pins: Id, Position, Label, Description, Metadata, Icon, ThemeColor / Color, Data and Class (CSS classes on the marker button). Markers without a valid position or with a duplicate Id are skipped with a warning. Pass a new list to change them.
Shapes IEnumerable<DwsMapShape>? null Lines, areas and circles: DwsMapShape.Polyline / Polygon / Circle, with Label, ThemeColor / Color, StrokeWidth (px), FillOpacity and Dashed. Invalid geometry or a duplicate Id is skipped with a warning.
AllowSelection bool true Clicking a marker (or Enter/Space) selects it and pins its detail; clicking it again, the close button or Escape deselects it.
SelectedMarkerId string? null Id of the selected marker; bind it with @bind-SelectedMarkerId.
ShowMarkerDetail bool true Shows the detail of the hovered or focused marker, and of the selected one until it is deselected.
MarkerDetailTemplate RenderFragment<DwsMapMarker>? null Content of the marker detail. Null shows the label, description and metadata.
ClusterMarkers bool false Merges markers closer together than ClusterRadius pixels into a badge with their count; clicking it zooms in until they separate. Worked out each time the map comes to rest; the selected marker always keeps its pin, and nothing is clustered at MaxZoom.
ClusterRadius int 60 How close markers have to be, in pixels on screen, to form a cluster (at least 10).
AutoClusterMarkers bool true With more markers than AutoClusterThreshold the map clusters them even while ClusterMarkers is off. Off leaves clustering to ClusterMarkers alone.
AutoClusterThreshold int 100 The number of markers above which AutoClusterMarkers starts clustering.
MarkerKeyboardNavigation bool true The markers and clusters are one Tab stop: Tab reaches the one focused last (at first the one nearest the middle of the view), the arrow keys move to the nearest marker or cluster in that direction, Home / End to the first / last, plus and minus zoom. Off makes every marker a Tab stop of its own.
FitContentOnLoad bool false Fits every marker and shape into the map once, the first time the map has been measured and has something to show (also when the markers arrive later).
ShowZoomControls bool true Shows the zoom in / zoom out buttons; they are disabled at MaxZoom / MinZoom.
ShowResetControl bool true Shows the button that returns to the first Center and Zoom (also the Home key).
ShowAttribution bool true Shows where the map data comes from.
CullMarkers bool? null Draws only the markers and clusters in the view and one view's width and height around it, worked out each time the map comes to rest; the selected and the hovered or focused marker are always drawn. Null switches it on with more markers than AutoClusterThreshold, true and false force it. Dragging further than one view at once shows the markers there when the map stops.
ShowScaleBar bool true Shows a scale bar in the bottom corner opposite the attribution: a round distance (1, 2 or 5 times a power of ten) at the latitude of the middle of the view, updated when the map comes to rest.
ScaleBarUnits DwsMapScaleUnits DwsMapScaleUnits.Auto Auto uses kilometres and metres, or miles and feet where the region of the current culture is not metric (en-US); Metric and Imperial force one.
ShowLocateControl bool false Adds a 'my position' button to the controls. Pressing it asks the browser for the position (with its permission prompt), moves the map there and marks it with a dot and an accuracy circle. Denied, unavailable, timed out or unsupported (no secure connection) is shown in a message on the map and raised through OnLocateFailed; nothing is thrown.
EditShapeId string? null The Id of the shape in Shapes whose points are being edited (a polyline or a polygon; it may start without points). While it is set a click on the map adds a point at the end, the points are marked with dots, and a list under the map lets the user change the coordinates of each point, move it in the order and remove it. The shape itself is not written to: assign DwsMapShapeChangedEventArgs.Points in OnShapeChanged to keep the edit. The list is a second element after the map.
ShowShapeEditor bool true Shows the list of points under the map while a shape is edited. False leaves the list to the application; the dots, the click on the map, the methods and the event still work.
LocateZoom double 14 The zoom the map moves to at the position, unless it is zoomed in further already.
LocateTimeoutSeconds int 10 How long the browser may take to find the position, 1 to 45 seconds.
LocateHighAccuracy bool false Asks for the most accurate position the device has (GPS); slower and uses more power.
FollowPosition bool false Keeps the map on the user's position (@bind-FollowPosition): a watch of the browser's position instead of one reading. The position marker and its accuracy circle move with every reading without a render of the map; the map is centred on the first reading (at LocateZoom, unless zoomed in further) and afterwards moved only when the position comes nearer than a fifth of the view to its edge. Moving the map by hand (a drag, the arrow or page keys, Home, the reset button) switches it off, announced through a role="status" region; zooming does not. A position that cannot be read switches it off with the message of the 'my position' button and OnLocateFailed. Only a change of the parameter starts or stops the watch, so a parent that keeps passing true does not switch it back on. Uses LocateTimeoutSeconds (for the first reading) and LocateHighAccuracy. The watch and its listeners end with the map. Needs a secure connection.
ShowFollowControl bool true With ShowLocateControl: a 'follow my position' toggle after the 'my position' button (aria-pressed).
ShowHeading bool false While the map follows the position: a wedge on the position marker for the direction - the direction of travel the browser reports while the device moves, else the device's compass where the browser has one without asking (deviceorientationabsolute, Android). iOS asks the user, and only from a user gesture: pressing the follow toggle asks, and a refusal leaves the wedge out. No direction, no wedge, no error.
WrapWorld bool true Repeats the world to the east and west: the map pans on across the antimeridian, markers and shapes show on the copy nearest the middle, and every edge of a line or area takes the short way (under 180° of longitude; add points for a longer one). FitContentAsync fits content across 180° the short way. Off while MaxBounds is set.
MaxBounds DwsGeoBounds? null Keeps the view inside this area; an area smaller than the map stays centred. An invalid area (corners swapped) is ignored with a warning.
CooperativeGestures bool true The wheel zooms only with Ctrl (or ⌘) and one finger scrolls the page on touch screens (two move the map); a hint says so. Off: the wheel zooms directly and one finger moves the map.
LandColor DwsColor DwsColor.Undefined Theme color of the land. Undefined uses the page background.
WaterColor DwsColor DwsColor.Undefined Theme color of the water. Undefined uses a tint of the info color.
BorderColor DwsColor DwsColor.Undefined Theme color of the country borders. Undefined uses a muted text color.
MarkerColor DwsColor DwsColor.Primary Theme color of markers that set neither ThemeColor nor Color.
ShapeColor DwsColor DwsColor.Primary Theme color of shapes that set neither ThemeColor nor Color.
Name Typ Description
CenterChanged EventCallback<DwsGeoPoint> Raised when the map has come to rest at another center; used by @bind-Center.
ZoomChanged EventCallback<double> Raised when the map has come to rest at another zoom; used by @bind-Zoom.
OnViewChanged EventCallback<DwsMapViewChangedEventArgs> Raised when the map has come to rest after moving, zooming or resizing, with its Center, Zoom and visible Bounds.
OnLocated EventCallback<DwsMapLocatedEventArgs> Raised with the position and its accuracy in meters when the browser reported the user's position.
FollowPositionChanged EventCallback<bool> For @bind-FollowPosition: raised when the map started or stopped following by itself (the toggle, a move of the map by hand, a failure).
OnFollowPositionChanged EventCallback<DwsMapFollowChangedEventArgs> Raised when the map started or stopped following the position: Following, Reason (Toggled, Requested, Panned, Failed) and for a failure Failure (DwsMapLocateStatus). While it follows, OnLocated is raised for every reading, with HeadingDegrees while the device moves.
OnLocateFailed EventCallback<DwsMapLocateStatus> Raised with Denied, Unavailable, Timeout or Unsupported when the position could not be read.
OnMapClick EventCallback<DwsMapClickEventArgs> Raised when the map itself is clicked (not a marker, shape or control, and not at the end of a drag), with the Position and, with InteractiveCountries, the Country under the pointer.
OnShapeChanged EventCallback<DwsMapShapeChangedEventArgs> Raised when a point of the edited shape was added, changed, moved in the order or removed: Shape, Points (the points after the change), Change (PointAdded, PointMoved, PointRemoved, PointsReordered) and Index.
OnMarkerClick EventCallback<DwsMapMarkerEventArgs> Raised when a marker is clicked or activated with Enter/Space. Not raised while disabled or in permission select mode.
OnMarkerMouseEnter EventCallback<DwsMapMarkerEventArgs> Raised when the pointer enters a marker or the marker gets keyboard focus.
OnMarkerMouseLeave EventCallback<DwsMapMarkerEventArgs> Raised when the pointer leaves a marker or the marker loses keyboard focus.
SelectedMarkerIdChanged EventCallback<string?> Raised when a marker is selected or deselected; used by @bind-SelectedMarkerId.
OnShapeClick EventCallback<DwsMapShapeEventArgs> Raised when a shape is clicked or activated with Enter/Space. Shapes only react to the pointer and keyboard when this or a hover event has a handler.
OnShapeMouseEnter EventCallback<DwsMapShapeEventArgs> Raised when the pointer enters a shape or the shape gets keyboard focus. With a handler shapes react to the pointer and Tab reaches them.
OnShapeMouseLeave EventCallback<DwsMapShapeEventArgs> Raised when the pointer leaves a shape or the shape loses keyboard focus.
OnClusterClick EventCallback<DwsMapClusterEventArgs> Raised when a cluster is clicked or activated with Enter/Space, with its Markers and Bounds, before the map zooms in to them.
OnCountryClick EventCallback<DwsMapCountryEventArgs> Raised when a country is clicked while InteractiveCountries is on: its Id, IsoA3, IsoA2 and Name (current language), NameEnglish, NameGerman, and the Position.
Name Typ Default Description
Element ElementReference The associated web component. May be null if accessed before the component is rendered.
ComponentGuid Guid Unique identifier for the component.
TypeString string The name of the component type, obtained from reflection.
Authorized_RegisterEnabled bool false Indicates whether this component is enabled through a permission registry.
Authorized_RegisterSelected bool false Indicates whether this component is selected in permission selection mode.
GetInitializedState bool false Returns whether the component is initialized.
GetRenderModeState DwsRenderMode Returns the current render mode.
GetComponentState DwsComponentStateType Returns the current component state.
GetIsInteractiveState bool false Returns whether the component is interactive.
GetIsPrerenderingState bool false Returns whether the component is prerendering.
GetComponentLoadingState bool false Returns whether the component is loading.
IsFormBusy bool false Whether the DwsForm (or DwsFormBusyRegion) around the component is locked because its submit handler is running. The state itself is the cascaded FormBusyState (IDwsFormBusyState).
Name Typ Parameters Description
DebugInfo void Logs debug information about the component.
UpdateState void Updates the component's state and triggers StateHasChanged.
UpdateStateAsync Task Asynchronously updates the component's state and triggers StateHasChanged.
Dispose void Disposes the component and releases resources.
FocusAsync ValueTask bool containedInScrollableList Sets focus to the component's element.
Name Typ Default Description
Name string Required unique identifier for the component within its container.
Visible bool true Determines if the component is visible in the UI.
Disabled bool false Disables the form control, ensuring it doesn't participate in form submission.
ComponentNameSpace string The namespace for permission-based access control.
PermissionKey string? null A stable key that takes the place of Name in the generated permission namespace (Page.PermissionKey): the stored permission survives a rename, and components that share a key share one permission entry. Null: keyed by Name. Read once, when the component registers; an explicit ComponentNameSpace wins.
Class string Optional CSS class names.
Style string Optional in-line styles.
Tag object An optional user-defined object to store any additional data with the component.
BackReference DwsReference A reference to the enclosing component.
ID string The HTML ID attribute for the component.
AdditionalAttributes Dictionary<string, object> Additional HTML attributes for the component's root element.
IgnorePermissionChecks bool false Bypasses all permission checks for this component.
IgnorePermissionSelection bool false Ignore permission selection mode for this component.
IgnoreFormBusy bool false Takes the component out of the submit lock of the DwsForm (or DwsFormBusyRegion) around it: IsFormBusy stays false for it.
Name Typ Description
OnInitializedCallbackStarted EventCallback Callback when OnInitialized starts.
OnInitializedCallback EventCallback Callback during OnInitialized.
OnInitializedCallbackCompleted EventCallback Callback when OnInitialized completes.
OnInitializedAsyncCallbackStarted EventCallback Callback when OnInitializedAsync starts.
OnInitializedAsyncCallback EventCallback Callback during OnInitializedAsync.
OnInitializedAsyncCallbackCompleted EventCallback Callback when OnInitializedAsync completes.
OnIsComponentLoadingChanged EventCallback<bool> Callback when IsComponentLoading changes.
OnCurrentRenderModeChanged EventCallback<DwsRenderMode> Callback when CurrentRenderMode changes.
OnComponentStateChanged EventCallback<DwsComponentStateType> Callback when ComponentState changes.
An error has occurred. This app may no longer respond until reloaded.