MapView¶
Namespace: ThinkGeo.UI.Blazor
public class MapView : Microsoft.AspNetCore.Components.ComponentBase, Microsoft.AspNetCore.Components.IComponent, Microsoft.AspNetCore.Components.IHandleEvent, Microsoft.AspNetCore.Components.IHandleAfterRender, System.IDisposable, System.IAsyncDisposable
Inheritance object → ComponentBase → MapView
Implements IComponent, IHandleEvent, IHandleAfterRender, IDisposable, IAsyncDisposable
Properties¶
AdornmentOverlay¶
public AdornmentOverlay AdornmentOverlay { get; internal set; }
Property Value¶
AdornmentOverlaySetting¶
public RenderFragment AdornmentOverlaySetting { get; set; }
Property Value¶
Center¶
public PointShape Center { get; set; }
Property Value¶
PointShape
EditOverlay¶
public EditOverlay EditOverlay { get; internal set; }
Property Value¶
EditOverlaySetting¶
public RenderFragment EditOverlaySetting { get; set; }
Property Value¶
Height¶
public int Height { get; set; }
Property Value¶
ActualHeight¶
public int ActualHeight { get; private set; }
Property Value¶
Id¶
public string Id { get; set; }
Property Value¶
IsLoaded¶
Whether the map is drawn in the browser with the overlays it was declared with attached to it. An application that waits for this can draw on any of those overlays at once.
public bool IsLoaded { get; private set; }
Property Value¶
WhenReady¶
Completes when the map has been created in the browser and all overlays declared in the component have finished initializing. The task is canceled if the map is disposed before it becomes ready, and faults if initialization fails.
public Task WhenReady { get; }
Property Value¶
OnReady¶
Occurs once when the map and its declared overlays are ready for browser operations.
public EventCallback OnReady { get; set; }
Property Value¶
MapTools¶
public MapTools MapTools { get; internal set; }
Property Value¶
MapToolsSetting¶
public RenderFragment MapToolsSetting { get; set; }
Property Value¶
MarkerOverlay¶
public MarkerOverlay MarkerOverlay { get; internal set; }
Property Value¶
MarkerOverlaySetting¶
public RenderFragment MarkerOverlaySetting { get; set; }
Property Value¶
MapUnit¶
public GeographyUnit MapUnit { get; set; }
Property Value¶
GeographyUnit
MaximumScale¶
This property gets and sets a maximum scale when navigating the map.
When you keep zooming out, and the target scale is bigger than the maximum scale, the zooming operation will be stopped. It is applied when the map is created.
The map stops at the closest zoom step that does not go past the scale, so the effective stop is never coarser than the scale you set. Use this rather than trimming the MapView.ZoomLevelSet, which is the tile scale ladder.
public double MaximumScale { get; set; }
Property Value¶
MinimumScale¶
This property gets and sets a minimum scale when navigating the map.
When you keep zooming in, and the target scale is smaller than the minimum scale, the zooming operation will be stopped. It is applied when the map is created.
The map stops at the closest zoom step that does not go past the scale, so the effective stop is never finer than the scale you set. When it is left unset, the map can zoom in as far as the MapView.ZoomLevelSet has zoom levels.
public double MinimumScale { get; set; }
Property Value¶
Renderer¶
This property gets or sets which renderer draws the map.
It is left alone as a rule. The default, MapViewRenderer.Auto, gives the map to MapViewRenderer.MapLibre - which can tilt and raise buildings - when everything it has been given is in web mercator, and to MapViewRenderer.OpenLayers when anything is not, because that is the one that draws any projection. Naming a renderer is how an application overrules that.
It is applied when the map is created; a map cannot change renderer afterwards.
public MapViewRenderer Renderer { get; set; }
Property Value¶
Pitch¶
This property gets or sets how far the map is tilted away from straight down, in degrees, from 0 to 85. It is the same angle, measured the same way, as TiltAngle on the desktop map.
The map follows this value: set it, and the map tilts. MapView.SetPitchAsync(double) does the same thing from code that is not a render - an event handler, a timer - and leaves this property where it was.
Tilting does not change what the map covers: the extent stays the ground the map has at its centre and scale looking straight down.
Only MapViewRenderer.MapLibre can tilt a map.
public double Pitch { get; set; }
Property Value¶
Bearing¶
This property gets or sets the compass direction the top of the map points to, in degrees counter-clockwise from north. The desktop map measures the same turn the other way round, so this is the negation of its RotationAngle.
The map follows this value: set it, and the map turns. MapView.SetBearingAsync(double) does the same thing from code that is not a render - an event handler, a timer - and leaves this property where it was.
Turning does not change what the map covers: the extent stays the ground the map has at its centre and scale looking straight down.
Supported by both OpenLayers and MapLibre.
public double Bearing { get; set; }
Property Value¶
EnableAltDragRotation¶
Enables Alt-drag rotation on OpenLayers in addition to its default Alt+Shift-drag and touch gestures. Set before the map is created. MapLibre gestures are unchanged.
public bool EnableAltDragRotation { get; set; }
Property Value¶
DisplayProjection¶
This property gets or sets how the map's plane reaches the screen - flat, or as a ball. The data does not move: tiles and coordinates stay web mercator, and this changes only the shape they are drawn in.
The map follows this value: set it, and the map changes projection. The browser renderer animates the change over a time of its own, which it does not let a caller name. MapView.SetDisplayProjectionAsync(DisplayProjection) does the same from code that is not a render.
Only MapViewRenderer.MapLibre draws anything but web mercator.
public DisplayProjection DisplayProjection { get; set; }
Property Value¶
RestrictExtent¶
This property gets or sets an extent to restrict the map navigation.
Panning keeps the visible extent inside this range on each axis where it fits. If the viewport is larger on an axis, its center is held at the range center without changing the zoom level. It is applied when the map is created.
To limit only north and south, for example to stop at the poles while the map still wraps around the dateline, give the extent the world's north and south bounds and an east-west range wider than the world.
public RectangleShape RestrictExtent { get; set; }
Property Value¶
RectangleShape
OnClick¶
public EventCallback<ClickedMapViewEventArgs> OnClick { get; set; }
Property Value¶
EventCallback<ClickedMapViewEventArgs>
OnCurrentExtentChanged¶
public EventCallback<CurrentExtentChangedMapViewEventArgs> OnCurrentExtentChanged { get; set; }
Property Value¶
EventCallback<CurrentExtentChangedMapViewEventArgs>
OnCurrentExtentChangedInAnimation¶
Raised while the map view moves. Updates are limited to about 20 per second. Subscribe only when a live extent readout is needed; MapView.OnCurrentExtentChanged continues to report the final extent after the movement ends.
public EventCallback<CurrentExtentChangedInAnimationMapViewEventArgs> OnCurrentExtentChangedInAnimation { get; set; }
Property Value¶
EventCallback<CurrentExtentChangedInAnimationMapViewEventArgs>
OnDoubleClick¶
public EventCallback<DoubleClickedMapViewEventArgs> OnDoubleClick { get; set; }
Property Value¶
EventCallback<DoubleClickedMapViewEventArgs>
OnMouseMove¶
public EventCallback<MouseMovingMapViewEventArgs> OnMouseMove { get; set; }
Property Value¶
EventCallback<MouseMovingMapViewEventArgs>
OnSizeChanged¶
public EventCallback<SizeChangedMapViewEventArgs> OnSizeChanged { get; set; }
Property Value¶
EventCallback<SizeChangedMapViewEventArgs>
Overlays¶
public GeoCollection<Overlay> Overlays { get; }
Property Value¶
GeoCollection<Overlay>
OverlaysSetting¶
public RenderFragment OverlaysSetting { get; set; }
Property Value¶
PopupOverlay¶
public PopupOverlay PopupOverlay { get; internal set; }
Property Value¶
PopupOverlaySetting¶
public RenderFragment PopupOverlaySetting { get; set; }
Property Value¶
Width¶
public int Width { get; set; }
Property Value¶
ActualWidth¶
public int ActualWidth { get; private set; }
Property Value¶
ProgressiveZooming¶
public bool ProgressiveZooming { get; set; }
Property Value¶
Zoom¶
public int Zoom { get; set; }
Property Value¶
BackgroundColor¶
public GeoColor BackgroundColor { get; set; }
Property Value¶
GeoColor
ZoomScales¶
Gets or sets the scale ladder the map zooms along and its tiles are built on: the scale at zoom 0, at zoom 1, and so on. Each scale decides the world extent a tile at that level covers, so a LayerOverlay renders its tiles against it, and the number of scales is how far the map can zoom in. Setting MapView.MapUnit to GeographyUnit.Meter replaces it with the ThinkGeo Cloud Maps ladder, which is the web mercator one every tile service uses.
This is not the way to limit navigation. Use MapView.MinimumScale and MapView.MaximumScale for that; they stop the zooming without changing the scale the tiles are drawn at.
public Collection<double> ZoomScales { get; set; }
Property Value¶
ZoomLevelSet¶
The scale ladder as a ZoomLevelSet. Obsolete: a map only needs the scales, and the styles a ZoomLevelSet carries per level belong on a layer, where they are read. Use MapView.ZoomScales; a ZoomLevelSet you already have becomes one with zoomLevelSet.GetScales(). Setting this still works and sets the scales; reading it builds a set from them.
public ZoomLevelSet ZoomLevelSet { get; set; }
Property Value¶
ZoomLevelSet
MapViewSizeUnitType¶
public MapViewSizeUnitType MapViewSizeUnitType { get; set; }
Property Value¶
ActiveRenderer¶
The renderer this map is drawn by. When MapView.Renderer names one this is that one; when it is MapViewRenderer.Auto this is what the map chose, which is known once the map has been created.
public MapViewRenderer ActiveRenderer { get; }
Property Value¶
Constructors¶
MapView()¶
public MapView()
Methods¶
BuildRenderTree(RenderTreeBuilder)¶
protected void BuildRenderTree(RenderTreeBuilder __builder)
Parameters¶
__builder RenderTreeBuilder
Returns¶
GetCurrentExtentAsync()¶
public Task<RectangleShape> GetCurrentExtentAsync()
Returns¶
GetWorldCoordinateFromClientAsync(double, double)¶
Converts a browser client coordinate to a world coordinate for this map.
public Task<PointShape> GetWorldCoordinateFromClientAsync(double clientX, double clientY)
Parameters¶
clientX double
Client X coordinate from a browser pointer/drag event.
clientY double
Client Y coordinate from a browser pointer/drag event.
Returns¶
Task<PointShape>
The world coordinate or null when conversion fails.
PanToAsync(PointShape)¶
public Task PanToAsync(PointShape center)
Parameters¶
center PointShape
Returns¶
GetCenterAsync()¶
public Task<PointShape> GetCenterAsync()
Returns¶
SetCenterAsync(PointShape)¶
public Task SetCenterAsync(PointShape center)
Parameters¶
center PointShape
Returns¶
ZoomInAsync()¶
public Task ZoomInAsync()
Returns¶
ZoomOutAsync()¶
public Task ZoomOutAsync()
Returns¶
SetMapToolVisibilityAsync(MapToolKind, bool)¶
Shows or hides an existing navigation control without rebuilding the map.
public Task SetMapToolVisibilityAsync(MapToolKind tool, bool visible)
Parameters¶
tool MapToolKind
visible bool
Returns¶
ZoomToMinimumZoomAsync()¶
Zooms out to the coarsest scale in the map's normal scale range. Active navigation limits can still keep the map at a closer scale.
public Task ZoomToMinimumZoomAsync()
Returns¶
ZoomToCenterAsync(int, PointShape)¶
public Task ZoomToCenterAsync(int zoom, PointShape center)
Parameters¶
zoom int
center PointShape
Returns¶
ZoomToAsync(PointShape, double, Nullable<double>, int)¶
Moves the camera to a centre, a scale and a bearing: at once, or over a duration in milliseconds at a steady pace, the way the desktop map's ZoomToAsync moves it. The bearing is the compass direction that points up the screen; 0 puts north up, and null, the default, keeps the bearing the map has - as the desktop map's ZoomToAsync keeps its rotation.
public Task ZoomToAsync(PointShape center, double scale, Nullable<double> bearing, int durationInMilliseconds)
Parameters¶
center PointShape
scale double
bearing Nullable<double>
durationInMilliseconds int
Returns¶
ZoomToExtentAsync(RectangleShape)¶
Shows the whole of an extent, as large as the map's size allows: the map is centred on it and zoomed so that both of its sides fit.
public Task ZoomToExtentAsync(RectangleShape extent)
Parameters¶
extent RectangleShape
Returns¶
GetPitchAsync()¶
Returns how far the map is tilted away from straight down, in degrees.
public Task<double> GetPitchAsync()
Returns¶
SetPitchAsync(double)¶
Tilts the map away from straight down, in degrees, from 0 to 85. 0 looks straight down; the further it goes the more the ground is seen edge on. A value outside that range is brought into it, as it is on the desktop map.
public Task SetPitchAsync(double pitch)
Parameters¶
pitch double
Returns¶
ExportImageAsync(string)¶
Saves the map as it is on screen to a PNG the browser downloads. The picture is the map's own canvas read back at screen resolution - the view the person is looking at, with whatever pan, zoom and tilt they have set - so move the map first, then call this.
public Task ExportImageAsync(string fileName)
Parameters¶
fileName string
The name the browser saves the file as.
Returns¶
GetImageAsync()¶
The map as it is drawn now, as a PNG - what MapView.ExportImageAsync(string) saves in the browser, handed to the application instead: to put in a report, draw into a PDF, keep on the server. The picture travels over the circuit; a large map needs the hub's receive limit raised.
public Task<Byte[]> GetImageAsync()
Returns¶
Task<Byte[]>
The PNG's bytes.
SetNavigationLimitsAsync(RectangleShape, double, double)¶
Turns the navigation limits on or off while the map runs. MapView.RestrictExtent, MapView.MinimumScale and MapView.MaximumScale are applied when the map is created; this applies a new set afterwards, so an application can let the person switch them. Pass null for the extent, 0 for a scale, to lift that one.
public Task SetNavigationLimitsAsync(RectangleShape restrictExtent, double minimumScale, double maximumScale)
Parameters¶
restrictExtent RectangleShape
The rectangle the view is kept inside, or null for none.
minimumScale double
The most zoomed-in scale allowed, or 0 for none.
maximumScale double
The most zoomed-out scale allowed, or 0 for none.
Returns¶
SetDisplayProjectionAsync(DisplayProjection)¶
Draws the map in another projection, easing from the one it is in.
public Task SetDisplayProjectionAsync(DisplayProjection projection)
Parameters¶
projection DisplayProjection
The projection to draw in.
Returns¶
Remarks:
Nothing is refetched and nothing is reprojected: the tiles the map holds are the same tiles, drawn through a different shape. The browser renderer animates the change; how long it takes is its own, and a caller cannot name it. A map the browser renderer is not drawing throws, the same as tilting one does.
GetBearingAsync()¶
Returns the compass direction the top of the map points to, in degrees counter-clockwise from north.
public Task<double> GetBearingAsync()
Returns¶
SetBearingAsync(double)¶
Turns the map, in degrees counter-clockwise from north.
public Task SetBearingAsync(double bearing)
Parameters¶
bearing double
Returns¶
OnAfterRenderAsync(bool)¶
protected Task OnAfterRenderAsync(bool firstRender)
Parameters¶
firstRender bool
Returns¶
a(string)¶
internal static bool a(string )
Parameters¶
`` string
Returns¶
DisposeAsync()¶
public ValueTask DisposeAsync()