Skip to content

Commit dd93daf

Browse files
authored
Maps component (#6531)
* maps * demo * docs * xml comments * fix markers * rename Source param * rename Coordinate params * renames of apis * ViewChangedInfo * ViewUpdated * restructure args * regions * docs * zagreb into split * clean api * view sync
1 parent 5570f97 commit dd93daf

70 files changed

Lines changed: 5310 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Blazorise.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
<Project Path="Source/Extensions/Blazorise.LoadingIndicator/Blazorise.LoadingIndicator.csproj" />
7070
<Project Path="Source/Extensions/Blazorise.LottieAnimation/Blazorise.LottieAnimation.csproj" />
7171
<Project Path="Source/Extensions/Blazorise.Markdown/Blazorise.Markdown.csproj" />
72+
<Project Path="Source/Extensions/Blazorise.Maps/Blazorise.Maps.csproj" />
7273
<Project Path="Source/Extensions/Blazorise.PdfViewer/Blazorise.PdfViewer.csproj" />
7374
<Project Path="Source/Extensions/Blazorise.QRCode/Blazorise.QRCode.csproj" />
7475
<Project Path="Source/Extensions/Blazorise.RichTextEdit/Blazorise.RichTextEdit.csproj" />

CREDITS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,45 @@ SOFTWARE.
4040

4141
## Project
4242

43+
Leaflet
44+
45+
## Source
46+
47+
- https://github.com/Leaflet/Leaflet
48+
49+
## License
50+
51+
BSD 2-Clause License
52+
53+
Copyright (c) 2010-2023, Volodymyr Agafonkin
54+
Copyright (c) 2010-2011, CloudMade
55+
All rights reserved.
56+
57+
Redistribution and use in source and binary forms, with or without
58+
modification, are permitted provided that the following conditions are met:
59+
60+
1. Redistributions of source code must retain the above copyright notice, this
61+
list of conditions and the following disclaimer.
62+
63+
2. Redistributions in binary form must reproduce the above copyright notice,
64+
this list of conditions and the following disclaimer in the documentation
65+
and/or other materials provided with the distribution.
66+
67+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
68+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
69+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
70+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
71+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
72+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
73+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
74+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
75+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
76+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77+
78+
---
79+
80+
## Project
81+
4382
@microsoft/fluentui
4483

4584
## Source

Demos/Blazorise.Demo/Blazorise.Demo.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ProjectReference Include="..\..\Source\Extensions\Blazorise.LoadingIndicator\Blazorise.LoadingIndicator.csproj" />
1919
<ProjectReference Include="..\..\Source\Extensions\Blazorise.LottieAnimation\Blazorise.LottieAnimation.csproj" />
2020
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Markdown\Blazorise.Markdown.csproj" />
21+
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Maps\Blazorise.Maps.csproj" />
2122
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Gantt\Blazorise.Gantt.csproj" />
2223
<ProjectReference Include="..\..\Source\Extensions\Blazorise.QRCode\Blazorise.QRCode.csproj" />
2324
<ProjectReference Include="..\..\Source\Extensions\Blazorise.RichTextEdit\Blazorise.RichTextEdit.csproj" />

Demos/Blazorise.Demo/Components/SideMenu.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Bar Breakpoint="Breakpoint.Desktop" NavigationBreakpoint="Breakpoint.Tablet"
1+
<Bar Breakpoint="Breakpoint.Desktop" NavigationBreakpoint="Breakpoint.Tablet"
22
Mode="BarMode.VerticalInline" CollapseMode="BarCollapseMode.Small" MenuToggleBehavior=BarMenuToggleBehavior.AllowSingleMenu>
33
<BarToggler />
44
<BarBrand>
@@ -316,6 +316,7 @@
316316
<BarDropdownItem To="tests/loadingindicator">Loading Indicator</BarDropdownItem>
317317
<BarDropdownItem To="tests/lottie-animation">Lottie Animation</BarDropdownItem>
318318
<BarDropdownItem To="tests/markdown">Markdown</BarDropdownItem>
319+
<BarDropdownItem To="tests/maps">Maps</BarDropdownItem>
319320
<BarDropdownItem To="tests/onetimeinput">One Time Input</BarDropdownItem>
320321
<BarDropdownItem To="tests/pdfviewer">Pdf Viewer</BarDropdownItem>
321322
<BarDropdownItem To="tests/qrcode">QR Code</BarDropdownItem>

Demos/Blazorise.Demo/Config.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Blazorise.Components;
55
using Blazorise.FluentValidation;
66
using Blazorise.LoadingIndicator;
7+
using Blazorise.Maps;
78
using Blazorise.RichTextEdit;
89
using FluentValidation;
910
using Microsoft.Extensions.DependencyInjection;
@@ -29,6 +30,7 @@ public static IServiceCollection SetupDemoServices( this IServiceCollection serv
2930
options.UseResize = true;
3031
} )
3132
.AddLoadingIndicator()
33+
.AddBlazoriseMaps()
3234
.AddBlazoriseFluentValidation()
3335
.AddBlazoriseGoogleReCaptcha( options =>
3436
{
Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
@page "/tests/maps"
2+
3+
<Row>
4+
<Column>
5+
<Card Margin="Margin.Is4.OnY">
6+
<CardHeader>
7+
<CardTitle>Maps</CardTitle>
8+
</CardHeader>
9+
<CardBody>
10+
<Buttons>
11+
<Button Color="Color.Primary" Clicked="@ShowSplit">
12+
Split
13+
</Button>
14+
<Button Color="Color.Primary" Clicked="@ShowCroatia">
15+
Croatia
16+
</Button>
17+
<Button Color="Color.Secondary" Clicked="@ZoomIn">
18+
Zoom In
19+
</Button>
20+
<Button Color="Color.Secondary" Clicked="@ZoomOut">
21+
Zoom Out
22+
</Button>
23+
</Buttons>
24+
</CardBody>
25+
<CardBody>
26+
<Map @ref="@mapRef"
27+
View="@view"
28+
ViewChanged="@OnViewChanged"
29+
Options="@options"
30+
Clicked="@OnMapClicked"
31+
Height="Height.Rem( 35 )">
32+
<MapTileLayer Source="https://tile.openstreetmap.org/{z}/{x}/{y}.png"
33+
Attribution="&copy; OpenStreetMap contributors" />
34+
<MapMarkerLayer TItem="MapPlace"
35+
Data="@places"
36+
IdSelector="@( place => place.Id )"
37+
CoordinateSelector="@( place => place.Coordinate )"
38+
TitleSelector="@( place => place.Name )"
39+
PopupTextSelector="@( place => place.Description )"
40+
MarkerClicked="@OnPlaceClicked" />
41+
<MapCircle Center="@split"
42+
Radius="1200"
43+
Style="@cityAreaStyle" />
44+
<MapPolyline Coordinates="@route"
45+
Style="@routeStyle" />
46+
<MapPolygon Rings="@polygon"
47+
Style="@polygonStyle" />
48+
</Map>
49+
</CardBody>
50+
<CardBody>
51+
<Paragraph Margin="Margin.Is0">
52+
Center: @view.Center.Latitude.ToString( "0.0000" ), @view.Center.Longitude.ToString( "0.0000" )
53+
| Zoom: @view.Zoom.ToString( "0.0" )
54+
| Last map click: @lastMapClick
55+
| Selected place: @selectedPlace
56+
</Paragraph>
57+
</CardBody>
58+
</Card>
59+
</Column>
60+
</Row>
61+
62+
@code {
63+
private Map mapRef;
64+
65+
private readonly MapCoordinate split = new( 43.5081, 16.4402 );
66+
67+
private MapView view = new()
68+
{
69+
Center = new( 43.5081, 16.4402 ),
70+
Zoom = 13,
71+
};
72+
73+
private MapOptions options = new()
74+
{
75+
Controls = new()
76+
{
77+
ShowScale = true,
78+
},
79+
};
80+
81+
private readonly MapShapeStyle cityAreaStyle = new()
82+
{
83+
StrokeColor = "#2f80ed",
84+
FillColor = "#2f80ed",
85+
FillOpacity = 0.12,
86+
};
87+
88+
private readonly MapShapeStyle routeStyle = new()
89+
{
90+
StrokeColor = "#d9480f",
91+
StrokeWidth = 4,
92+
};
93+
94+
private readonly MapShapeStyle polygonStyle = new()
95+
{
96+
StrokeColor = "#2f9e44",
97+
FillColor = "#2f9e44",
98+
FillOpacity = 0.16,
99+
};
100+
101+
private readonly List<MapPlace> places =
102+
[
103+
new( "riva", "Riva Promenade", new( 43.5073, 16.4379 ), "Waterfront promenade by the harbor." ),
104+
new( "diocletian-palace", "Diocletian's Palace", new( 43.5081, 16.4402 ), "Historic palace in the city center." ),
105+
new( "marjan", "Marjan Hill", new( 43.5107, 16.4147 ), "Forested hill and park west of the old town." ),
106+
];
107+
108+
private readonly IReadOnlyList<MapCoordinate> route =
109+
[
110+
new( 43.5073, 16.4379 ),
111+
new( 43.5081, 16.4402 ),
112+
new( 43.5094, 16.4349 ),
113+
new( 43.5107, 16.4147 ),
114+
];
115+
116+
private readonly IReadOnlyList<IReadOnlyList<MapCoordinate>> polygon =
117+
[
118+
[
119+
new( 43.5066, 16.4366 ),
120+
new( 43.5094, 16.4384 ),
121+
new( 43.5101, 16.4432 ),
122+
new( 43.5069, 16.4445 ),
123+
new( 43.5066, 16.4366 ),
124+
],
125+
];
126+
127+
private string lastMapClick = "none";
128+
private string selectedPlace = "none";
129+
130+
private Task ShowSplit()
131+
=> mapRef.SetView( split, 13 ).AsTask();
132+
133+
private Task ShowCroatia()
134+
{
135+
var bounds = new MapBounds(
136+
new MapCoordinate( 42.30, 13.40 ),
137+
new MapCoordinate( 46.60, 19.50 ) );
138+
139+
return mapRef.FitBounds( bounds, new() { Padding = new( 24, 24 ) } ).AsTask();
140+
}
141+
142+
private Task ZoomIn()
143+
=> mapRef.ZoomIn().AsTask();
144+
145+
private Task ZoomOut()
146+
=> mapRef.ZoomOut().AsTask();
147+
148+
private Task OnViewChanged( MapView changedView )
149+
{
150+
view = changedView;
151+
152+
return Task.CompletedTask;
153+
}
154+
155+
private Task OnMapClicked( MapMouseEventArgs eventArgs )
156+
{
157+
lastMapClick = $"{eventArgs.Coordinate.Latitude:0.0000}, {eventArgs.Coordinate.Longitude:0.0000}";
158+
159+
return Task.CompletedTask;
160+
}
161+
162+
private Task OnPlaceClicked( MapMarkerClickedEventArgs<MapPlace> eventArgs )
163+
{
164+
selectedPlace = eventArgs.Item.Name;
165+
166+
return Task.CompletedTask;
167+
}
168+
169+
private sealed record MapPlace( string Id, string Name, MapCoordinate Coordinate, string Description );
170+
}

Demos/Blazorise.Demo/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
@using Blazorise.SpinKit
2525
@using Blazorise.LoadingIndicator
2626
@using Blazorise.Markdown
27+
@using Blazorise.Maps
2728
@using Blazorise.Video
2829
@using Blazorise.QRCode
2930
@using Blazorise.Splitter

Documentation/Blazorise.Docs.Server/Startup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using Blazorise.Docs.Services.Search;
1717
using Blazorise.FluentValidation;
1818
using Blazorise.Icons.FontAwesome;
19+
using Blazorise.Maps;
1920
using Blazorise.RichTextEdit;
2021
using FluentValidation;
2122
using Microsoft.AspNetCore.Builder;
@@ -67,6 +68,7 @@ public void ConfigureServices( IServiceCollection services )
6768
} )
6869
.AddBlazoriseFluentValidation()
6970
.AddBlazoriseGoogleReCaptcha( x => x.SiteKey = Configuration[key: "ReCaptchaSiteKey"] )
71+
.AddBlazoriseMaps()
7072
.AddBlazoriseRouterTabs();
7173

7274
services.Configure<BlogOptions>( Configuration.GetSection( "Blog" ) );

Documentation/Blazorise.Docs/Blazorise.Docs.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<ProjectReference Include="..\..\Source\Extensions\Blazorise.PdfViewer\Blazorise.PdfViewer.csproj" />
4444
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Scheduler\Blazorise.Scheduler.csproj" />
4545
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Gantt\Blazorise.Gantt.csproj" />
46+
<ProjectReference Include="..\..\Source\Extensions\Blazorise.Maps\Blazorise.Maps.csproj" />
4647
<PackageReference Include="MailKit" />
4748
<PackageReference Include="MimeKit" />
4849
<PackageReference Include="Blazored.LocalStorage" />

Documentation/Blazorise.Docs/Layouts/DocsLayout.razor

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@
287287
<BarDropdownItem To="docs/extensions/list-view">ListView</BarDropdownItem>
288288
<BarDropdownItem To="docs/extensions/loadingindicator">LoadingIndicator</BarDropdownItem>
289289
<BarDropdownItem To="docs/extensions/lottie-animation">LottieAnimation</BarDropdownItem>
290+
<BarDropdownItem To="docs/extensions/maps" Flex="Flex.JustifyContent.Between">
291+
<DocsNewFeatureBadge>Maps</DocsNewFeatureBadge>
292+
</BarDropdownItem>
290293
<BarDropdownItem To="docs/extensions/markdown">Markdown</BarDropdownItem>
291294
<BarDropdownItem To="docs/extensions/onetimeinput" Flex="Flex.JustifyContent.Between">
292295
<DocsNewFeatureBadge>OneTimeInput</DocsNewFeatureBadge>

0 commit comments

Comments
 (0)