-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathOverviewMap.razor
More file actions
46 lines (41 loc) · 1.78 KB
/
OverviewMap.razor
File metadata and controls
46 lines (41 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
@page "/Controls/OverviewMap"
@rendermode InteractiveServer
@using AzureMapsControl.Components.Controls
@using AzureMapsControl.Components.Map
<AzureMap Id="map"
Controls="new AzureMapsControl.Components.Controls.Control[]
{
new AzureMapsControl.Components.Controls.OverviewMapControl(new AzureMapsControl.Components.Controls.OverviewMapControlOptions
{
ShowToggle = true,
Style = new AzureMapsControl.Components.Atlas.Either<AzureMapsControl.Components.Controls.ControlStyle, string>(AzureMapsControl.Components.Controls.ControlStyle.Auto)
},
AzureMapsControl.Components.Controls.ControlPosition.TopLeft),
new AzureMapsControl.Components.Controls.StyleControl(position: AzureMapsControl.Components.Controls.ControlPosition.TopRight)
}"
EventActivationFlags="MapEventActivationFlags.None().Enable(MapEventType.StyleData).Enable(MapEventType.Ready)"
OnStyleData="OnStyleData"
OnReady="OnMapReady"/>
@code {
private bool _mapReady = false;
private MapStyle? _style;
private OverviewMapControl? _overviewControl;
public async void OnMapReady(MapEventArgs eventArgs)
{
_mapReady = true;
SetStyle();
}
public async void OnStyleData(MapStyleDataEventArgs eventArgs)
{
_overviewControl = eventArgs.Map.Controls?.OfType<AzureMapsControl.Components.Controls.OverviewMapControl>()?.FirstOrDefault();
_style = eventArgs.Style;
SetStyle();
}
private async void SetStyle()
{
if (_mapReady && _overviewControl != null && _style.HasValue)
{
await _overviewControl.SetOptionsAsync(options => options.MapStyle = _style.Value);
}
}
}