Skip to content

Commit caf228a

Browse files
committed
Replaced Leaflet with OpenLayers for Web UI
1 parent 1c897e8 commit caf228a

16 files changed

+1278
-852
lines changed

Docs/demo-page.png

101 KB
Loading

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Using
4747
* [SkiaSharp](https://github.com/mono/SkiaSharp) for raster images processing.
4848
* [BitMiracle.LibTiff.NET](https://github.com/BitMiracle/libtiff.net) for reading source GeoTIFF files and creating output TIFF images.
4949
* [Npgsql](https://github.com/npgsql/npgsql) .NET data provider for PostgreSQL.
50-
* [Leaflet](https://github.com/Leaflet) for map demo page.
50+
* [OpenLayers](https://github.com/OpenLayers) with [OpenLayers LayerSwitcher](https://github.com/walkermatt/ol-layerswitcher) for displaying layers.
5151
* [NUnit](https://nunit.org/) for tests.
5252

5353
### Configuration file
@@ -82,7 +82,6 @@ Some improvements can be made for better using this application in real environm
8282
* Flexible settings of tile sources.
8383
* Configuration Web API / Web UI with authentication.
8484
* WMS and Vector Tiles (mvt) client in Web UI.
85-
* .NET 8 project and solution.
8685
* Compare with reference implementations (servers and clients).
8786
* Using metatiles for better tiles quality.
8887
* Include test dataset(s) created from free data.

Src/TileMapService/TileSources/HttpTileSource.cs

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ async Task ITileSource.InitAsync()
8686
Format = this.configuration.Format, // TODO: from source service/layer capabilities
8787
Title = title,
8888
Abstract = this.configuration.Abstract, // TODO: from source layer capabilities
89+
Attribution = this.configuration.Attribution,
8990
Tms = tms,
9091
Srs = srs,
9192
Location = this.configuration.Location,

Src/TileMapService/TileSources/LocalFilesTileSource.cs

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ Task ITileSource.InitAsync()
8585
Format = this.configuration.Format, // TODO: from file properties (extension)
8686
Title = title,
8787
Abstract = this.configuration.Abstract,
88+
Attribution = this.configuration.Attribution,
8889
Tms = this.configuration.Tms ?? false, // Default is tms=false for file storage
8990
Srs = srs,
9091
Location = this.configuration.Location,

Src/TileMapService/TileSources/PostGISTileSource.cs

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Task ITileSource.InitAsync()
4949
Format = ImageFormats.MapboxVectorTile,
5050
Title = title,
5151
Abstract = this.configuration.Abstract,
52+
Attribution = this.configuration.Attribution,
5253
Tms = this.configuration.Tms ?? true,
5354
Srs = Utils.SrsCodes.EPSG3857,
5455
Location = this.configuration.Location,

Src/TileMapService/TileSources/RasterTileSource.cs

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Task ITileSource.InitAsync()
7373
Format = ImageFormats.Png, // TODO: ? multiple output formats ?
7474
Title = title,
7575
Abstract = this.configuration.Abstract,
76+
Attribution = this.configuration.Attribution,
7677
Tms = false,
7778
Srs = U.SrsCodes.EPSG3857, // TODO: only EPSG:3857 'output' SRS currently supported
7879
Location = this.configuration.Location,

Src/TileMapService/appsettings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"id": "osm",
8282
"format": "png",
8383
"title": "OSM",
84+
"attribution": "OSM",
8485
"location": "https://tile.openstreetmap.de/{z}/{x}/{y}.png"
8586
},
8687
{
@@ -157,7 +158,7 @@
157158
"id": "geotiff2",
158159
"minzoom": 16,
159160
"maxzoom": 24,
160-
"title": "geotiff",
161+
"title": "geotiff2",
161162
"abstract": "Tiles from single GeoTIFF image",
162163
"location": "d:\\SQLDB\\GeoTIFF\\longxi.tif"
163164
}

Src/TileMapService/wwwroot/index.html

+30-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
<head>
44
<meta charset="utf-8" />
55
<title>Tile Map Service</title>
6-
<link rel="stylesheet" href="leaflet.css" />
6+
<script src="ol.js"></script>
7+
<script src="ol-layerswitcher.js"></script>
8+
<link rel="stylesheet" href="ol.css">
9+
<link rel="stylesheet" href="ol-layerswitcher.css" />
710
<style>
811
html, body {
912
height: 100%;
@@ -12,14 +15,35 @@
1215
margin: 0;
1316
background-color: white;
1417
}
18+
19+
/* OpenLayers LayerSwitcher styling */
20+
.layer-switcher {
21+
top: 0.5em;
22+
}
23+
24+
.layer-switcher ul {
25+
margin: 0 0.2em;
26+
}
27+
28+
.layer-switcher li input {
29+
left: 0;
30+
}
31+
32+
.layer-switcher li label {
33+
padding-left: 1.6em;
34+
padding-right: 0;
35+
font-size: 12px;
36+
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
37+
}
38+
39+
.layer-switcher.shown.layer-switcher-activation-mode-click > button {
40+
display: none;
41+
}
1542
</style>
1643
</head>
1744
<body>
18-
<script src="leaflet.js" type="text/javascript"></script>
19-
<script src="leaflet.gridlayer.tilegrid.js" type="text/javascript"></script>
20-
21-
<div id="mapMercator" style="height: 50%; min-height: 50%;"></div>
22-
<div id="mapGeodetic" style="height: 50%; min-height: 50%;"></div>
45+
<div id="mapOL3857" style="height: 60%;"></div>
46+
<div id="mapOL4326" style="height: 40%;"></div>
2347

2448
<script src="index.js" type="text/javascript"></script>
2549
</body>

0 commit comments

Comments
 (0)