Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
pergerch committed Apr 10, 2024
2 parents 4189469 + 88cd9cc commit f364788
Show file tree
Hide file tree
Showing 207 changed files with 124,615 additions and 56,764 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ jobs:
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
- name: Config
run: git config --global --add safe.directory /github/workspace
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
filter: tree:0
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
Expand Down
36 changes: 29 additions & 7 deletions OpenLayers.Blazor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenLayers.Blazor.Demo", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenLayers.Blazor.Demo.Server", "src\OpenLayers.Blazor.Demo.Server\OpenLayers.Blazor.Demo.Server.csproj", "{56CA5376-8AD9-481C-81B1-D82D0716989A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLayers.Blazor.Demo.Maui", "src\OpenLayers.Blazor.Demo.Maui\OpenLayers.Blazor.Demo.Maui.csproj", "{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenLayers.Blazor.Demo.Maui", "src\OpenLayers.Blazor.Demo.Maui\OpenLayers.Blazor.Demo.Maui.csproj", "{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLayers.Blazor.Tests", "test\OpenLayers.Blazor.Tests\OpenLayers.Blazor.Tests.csproj", "{D235BF12-E194-49CA-AB16-27E23D87B9C5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenLayers.Blazor.Tests", "test\OpenLayers.Blazor.Tests\OpenLayers.Blazor.Tests.csproj", "{D235BF12-E194-49CA-AB16-27E23D87B9C5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenLayers.Blazor.Demo.Components", "src\OpenLayers.Blazor.Demo.Components\OpenLayers.Blazor.Demo.Components.csproj", "{9BEEE062-7A06-4391-9934-B3963D62B50D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{67C34A9D-CA3C-4313-93E1-DE9564C8BCCB}"
ProjectSection(SolutionItems) = preProject
.gitattributes = .gitattributes
.gitignore = .gitignore
icon.png = icon.png
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6A316A55-944A-4222-ACE2-EFA591915C2E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{717EBEE2-DC73-4FFA-BF30-A3591D310620}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -30,21 +45,28 @@ Global
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56CA5376-8AD9-481C-81B1-D82D0716989A}.Release|Any CPU.Build.0 = Release|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Release|Any CPU.Build.0 = Release|Any CPU
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8}.Release|Any CPU.Deploy.0 = Release|Any CPU
{D235BF12-E194-49CA-AB16-27E23D87B9C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D235BF12-E194-49CA-AB16-27E23D87B9C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D235BF12-E194-49CA-AB16-27E23D87B9C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D235BF12-E194-49CA-AB16-27E23D87B9C5}.Release|Any CPU.Build.0 = Release|Any CPU
{9BEEE062-7A06-4391-9934-B3963D62B50D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9BEEE062-7A06-4391-9934-B3963D62B50D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9BEEE062-7A06-4391-9934-B3963D62B50D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9BEEE062-7A06-4391-9934-B3963D62B50D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{26DEF966-E500-4817-8D6D-C1AC0A3ACA02} = {6A316A55-944A-4222-ACE2-EFA591915C2E}
{558FC061-5215-43DC-A7C1-CE3DA8D3112A} = {6A316A55-944A-4222-ACE2-EFA591915C2E}
{56CA5376-8AD9-481C-81B1-D82D0716989A} = {6A316A55-944A-4222-ACE2-EFA591915C2E}
{0FEB3FC9-8E58-4AE7-B09B-7FA248687EC8} = {6A316A55-944A-4222-ACE2-EFA591915C2E}
{D235BF12-E194-49CA-AB16-27E23D87B9C5} = {717EBEE2-DC73-4FFA-BF30-A3591D310620}
{9BEEE062-7A06-4391-9934-B3963D62B50D} = {6A316A55-944A-4222-ACE2-EFA591915C2E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CD0B2594-9026-4061-B859-28912AB5C59F}
EndGlobalSection
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This is a map component based on [OpenLayers](https://openlayers.org/) to show different types and layers of maps from sources like OpenStreet, Bing, SwissTopo ary WMTS/WMS compatible source with some features like markes or shape drawing. The component has implemented the swiss specific coordination projection (VL03/VL95) and therefore can project map content from swisstopo (https://map.geo.admin.ch/).

## Major Changes

Starting fromn version 1.5, the coordinates are represented and defined according to EPSG. This means the input for a Coordinate object will be switched: Coordinate(1197650, 2604200) > Coordinate(2604200, 1197650) or new Coordinate(51, 0) > Coordinate(0, 51)

## Demo/Examples

https://openlayers-blazor-demo.laurent-christen.ch/
Expand All @@ -16,9 +20,9 @@ https://openlayers-blazor-demo.laurent-christen.ch/
```html
<head>
...
<link href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/7.3.0/ol.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/8.1.0/ol.min.css" rel="stylesheet" />
<link href="_content/SpatialFocus.OpenLayers.Blazor/OpenLayers.Blazor.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/7.3.0/dist/ol.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/openlayers/8.1.0/dist/ol.min.js"></script>
...
</head>
```
Expand All @@ -37,13 +41,13 @@ https://openlayers-blazor-demo.laurent-christen.ch/
</div>
</Popup>
<Features>
<Marker Type="MarkerType.MarkerPin" Coordinate="new Coordinate(1197650, 2604200)"></Marker>
<Marker Type="MarkerType.MarkerFlag" Coordinate="new Coordinate(1177650, 2624200)" Title="Hallo" BackgroundColor="#449933" Popup></Marker>
<Line Points="new []{new Coordinate(1197650, 2604200), new Coordinate(1177650, 2624200)}" BorderColor="cyan"></Line>
<Marker Type="MarkerType.MarkerPin" Coordinate="new Coordinate(2604200, 1197650)"></Marker>
<Marker Type="MarkerType.MarkerFlag" Coordinate="new Coordinate(2624200, 1177650)" Title="Hallo" BackgroundColor="#449933" Popup></Marker>
<Line Points="new []{new Coordinate(1197650, 2604200), new Coordinate(2624200, 1177650)}" BorderColor="cyan"></Line>
</Features>
</SwissMap>

<OpenStreetMap Style="height:480px; width:640px" Zoom="5" Center="new Coordinate(51,0)">
<OpenStreetMap Style="height:480px; width:640px" Zoom="5" Center="new Coordinate(0, 51)">
<Layers>
<Layer SourceType="SourceType.TileWMS"
Url="https://sedac.ciesin.columbia.edu/geoserver/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=gpw-v3%3Agpw-v3-population-density_2000&LANG=en"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
@using System.Reflection
@using System.IO
@if (_code != null)
{
<div class="container m-3" style="overflow: auto; width: 80%">
<h5>@Source</h5>
<pre class="code"><code class="html">
@_code
</code></pre>
<div class="card mt-2 mb-2">
<div class="card-header">
<h5 class="card-subtitle">@Source</h5>
</div>
<div class="card-body p-0">
<pre class="code m-0"><code class="html" style="text-wrap: wrap;">@_code</code></pre>
</div>
</div>
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Pages\BingMapDemo.razor" />
<EmbeddedResource Include="Pages\CustomWMTSMap.razor" />
<EmbeddedResource Include="Pages\GeoJsonDemo.razor" />
<EmbeddedResource Include="Pages\Index.razor" />
<EmbeddedResource Include="Pages\LayersDemo.razor" />
<EmbeddedResource Include="Pages\MarkersDemo.razor" />
<EmbeddedResource Include="Pages\OpenStreetMapDemo.razor" />
<EmbeddedResource Include="Pages\ShapesDemo.razor" />
<EmbeddedResource Include="Pages\SwissMapLayersDemo.razor" />
<EmbeddedResource Include="Pages\DrawDemo.razor" />
<EmbeddedResource Include="Pages\GermanGdzDemo.razor" />
<EmbeddedResource Include="Pages\FlightTracker.razor" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OpenLayers.Blazor\OpenLayers.Blazor.csproj" />
</ItemGroup>

</Project>
32 changes: 32 additions & 0 deletions src/OpenLayers.Blazor.Demo.Components/Pages/BingMapDemo.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@page "/bingmapdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">

<div class="card-header">
<h3 class="card-title">Bing Maps</h3>
</div>

<div class="card-body">
<input type="text" @bind-value="_key" width="400px" placeholder="Your Bing Maps Key from https://www.bingmapsportal.com/ ">
<select @bind="_layerselect">
<option value="Aerial">Aerial</option>
<option value="AerialWithLabelsOnDemand">Aerial with labels</option>
<option value="RoadOnDemand" selected>Road</option>
<option value="CanvasDark">Road dark</option>
<option value="OrdnanceSurvey">Ordnance Survey</option>
</select>
</div>
</div>

@if (!string.IsNullOrEmpty(_key))
{
<BingMap Style="height: 800px;" Class="card" ImagerySet="@(_layerselect != null ? Enum.Parse<BingMapImagerySet>(_layerselect) : BingMapImagerySet.RoadOnDemand)" Key="@_key"></BingMap>
}

<CodeView Source="BingMapDemo.razor" />

@code {
private string? _layerselect;
private string? _key;
}
16 changes: 16 additions & 0 deletions src/OpenLayers.Blazor.Demo.Components/Pages/CustomWMTSMap.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@page "/customdemo"
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
<h3 class="card-title">Custom WMTS Map</h3>
</div>
</div>

<Map Style="height:800px" Class="card" Zoom="5" Center="new Coordinate(-73, 40.72)" CoordinatesProjection="EPSG:4326">
<Layers>
<Layer SourceType="SourceType.XYZ" Url="@("https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x}")" CrossOrigin="anonymous" Format="image/png"></Layer>
</Layers>
</Map>

<CodeView Source="CustomWMTSMap.razor" />
103 changes: 103 additions & 0 deletions src/OpenLayers.Blazor.Demo.Components/Pages/DrawDemo.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
@page "/drawdemo/{MapType?}"
@using System.Text.Json
@rendermode Components.RenderMode.DefaultRenderMode

<div class="card mt-2 mb-2">
<div class="card-header">
<h3 class="card-title">Drawing Demo</h3>
</div>
<div class="card-body">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group" data-toggle="buttons">
<input type="checkbox" class="btn-check" id="btndraw" autocomplete="off" @bind="_enabledraw">
<label class="btn btn-outline-primary" for="btndraw">Draw</label>
<input type="checkbox" class="btn-check" id="btnedit" autocomplete="off" @bind="_enableedit">
<label class="btn btn-outline-primary" for="btnedit">Edit</label>
<input type="checkbox" class="btn-check" id="btnsnap" autocomplete="off" @bind="_snap">
<label class="btn btn-outline-primary" for="btnsnap">Snap</label>
<input type="checkbox" class="btn-check" id="btnfreehand" autocomplete="off" @bind="_freehand">
<label class="btn btn-outline-primary" for="btnfreehand">Freehand</label>
</div>
<select id="type" @bind="_shapeType">
<option value="@(ShapeType.Point)">Point</option>
<option value="@(ShapeType.LineString)">LineString</option>
<option value="@(ShapeType.Polygon)">Polygon</option>
<option value="@(ShapeType.Circle)">Circle</option>
</select>
<input type="color" class="form-control form-control-color" id="bgColorInput" title="Background" @bind="_styleOptions.Fill.Color">
<input type="color" class="form-control form-control-color" id="borderColorInput" title="Background" @bind="_styleOptions.Stroke.Color">
<input type="range" min="1" max="30" @bind="_styleOptions.Stroke.Width" title="Border Size">
<input type="button" class="btn btn-primary" value="Undo" @onclick="() => _map.Undo()" />
<input type="button" class="btn btn-secondary" value="Clear" @onclick="() => _map.ShapesList.Clear()" />
</div>
</div>
</div>

@if (MapType == "osm")
{
<OpenStreetMap @ref="_map" Style="height:800px;" Class="card" OnShapeAdded="StateHasChanged" EnableEditShapes="_enableedit" EnableNewShapes="_enabledraw" EnableShapeSnap="_snap" ShapeStyleCallback="(shape) => _styleOptions" NewShapeType="_shapeType" Freehand="_freehand">
</OpenStreetMap>
}
else
{
<SwissMap @ref="_map" Style="height: 800px;" Class="card" OnShapeAdded="StateHasChanged" EnableEditShapes="_enableedit" EnableNewShapes="_enabledraw" EnableShapeSnap="_snap" ShapeStyleCallback="(shape) => _styleOptions" NewShapeType="_shapeType" Freehand="_freehand">
<Features>
<Line Points="new[] { new Coordinate(2604200, 1197650), new Coordinate(2624200, 1177650) }" BorderColor="red" BorderSize="2"></Line>
<Circle Center="_center" Radius="2000" BorderSize="3" BorderColor="blue" BackgroundColor="#55229933"></Circle>
<Point Coordinate="new Coordinate(2683276.620804008, 1247123.8311215444)" BackgroundColor="green" Radius="20"></Point>
</Features>
</SwissMap>
}

@if (_map != null)
{
<div class="card mt-2 mb-2">
<div class="card-header">
<h5 class="card-title">Shapes</h5>
</div>
<div class="card-body">
@foreach (var shape in _map.ShapesList)
{
<p>
<strong>@shape.Id @shape.Type @shape.GeometryType</strong>
<ul>
@if (shape.Coordinates != null)
{
@JsonSerializer.Serialize(shape.Coordinates)
}
</ul>
</p>
}
</div>
</div>
}

<CodeView Source="DrawDemo.razor" />

@code {
[Parameter] public string? MapType { get; set; }
private Map? _map;
private ShapeType _shapeType = ShapeType.LineString;
private Coordinate _center = new(2604200, 1197650);
private bool _enabledraw, _enableedit, _snap = true, _freehand;

private StyleOptions _styleOptions = new StyleOptions()
{
Stroke = new StyleOptions.StrokeOptions()
{
Color = "#dd1111",
Width = 2
},
Fill = new StyleOptions.FillOptions()
{
Color = "#563d7c"
}
};

protected override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
StateHasChanged();
return base.OnAfterRenderAsync(firstRender);
}
}
Loading

0 comments on commit f364788

Please sign in to comment.