Skip to content

Commit c5c277f

Browse files
committed
1 parent 91a7466 commit c5c277f

File tree

4 files changed

+60
-50
lines changed

4 files changed

+60
-50
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
},
2222
"homepage": "https://github.com/simon04/tyrolean-map#readme",
2323
"dependencies": {
24-
"leaflet": "^1.9.4",
25-
"leaflet-control-geocoder": "^3.1.0",
26-
"leaflet.locatecontrol": "^0.83.0"
24+
"leaflet": "2.0.0-alpha",
25+
"leaflet-control-geocoder": "^3.2.0",
26+
"leaflet.locatecontrol": "jeffreykog/leaflet-locatecontrol#leaflet-v2"
2727
},
2828
"devDependencies": {
29-
"@types/leaflet": "^1.9.15",
30-
"@types/leaflet.locatecontrol": "^0.74.6",
29+
"@types/leaflet": "^1.9.18",
30+
"@types/leaflet.locatecontrol": "^0.82.0",
3131
"prettier": "^3.5.3",
3232
"pretty-quick": "^4.1.1",
3333
"vite": "^6.3.2"

src/app.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as L from 'leaflet';
1+
import {Map, Icon, Layer, TileLayer} from 'leaflet';
22
import 'leaflet/dist/leaflet.css';
33
import {Geocoder as GeocoderControl} from 'leaflet-control-geocoder';
44
import 'leaflet-control-geocoder/style.css';
@@ -8,17 +8,17 @@ import LeafletHash from './leaflet-fullHash';
88
import {CollapsableLayerControl} from './leaflet-collapsable-layer-control';
99
import './style.css';
1010

11-
const map = L.map('map').setView([47.3, 11.3], 9);
11+
const map = new Map('map').setView([47.3, 11.3], 9);
1212

1313
map.attributionControl.setPrefix(false);
1414
const collapsed = window.matchMedia && window.matchMedia('all and (max-width: 700px)').matches;
1515
const layers = new CollapsableLayerControl({}, {}, {collapsed: collapsed}).addTo(map);
1616

17-
delete (L.Icon.Default.prototype as any)._getIconUrl;
17+
delete (Icon.Default.prototype as any)._getIconUrl;
1818
import iconRetinaUrl from 'leaflet/dist/images/marker-icon-2x.png';
1919
import iconUrl from 'leaflet/dist/images/marker-icon.png';
2020
import shadowUrl from 'leaflet/dist/images/marker-shadow.png';
21-
L.Icon.Default.mergeOptions({
21+
Icon.Default.mergeOptions({
2222
iconRetinaUrl,
2323
iconUrl,
2424
shadowUrl,
@@ -50,15 +50,15 @@ const attributionST_CC0 = [
5050
];
5151
const attributionOsm = '<a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> (ODbL)';
5252

53-
const allMapLayers: Record<string, L.Layer> = {};
53+
const allMapLayers: Record<string, Layer> = {};
5454

5555
[
5656
{id: 'gdi_base_summer', title: 'Elektronische Karte Tirol: Sommer'},
5757
{id: 'gdi_base_winter', title: 'Elektronische Karte Tirol: Winter'},
5858
].forEach(({id, title}, idx) => {
5959
const imprint =
6060
'<a href="https://www.tirol.gv.at/statistik-budget/tiris/tiris-geodatendienste/impressum-elektronische-karte-tirol/">Elektronische Karte Tirol</a>';
61-
const layer = L.tileLayer(`https://wmts.kartetirol.at/wmts/${id}/${id}/{z}/{x}/{y}.jpeg80`, {
61+
const layer = new TileLayer(`https://wmts.kartetirol.at/wmts/${id}/${id}/{z}/{x}/{y}.jpeg80`, {
6262
maxZoom: 18,
6363
attribution: [...attribution, imprint, attributionOsm].join(', '),
6464
});
@@ -77,7 +77,7 @@ const allMapLayers: Record<string, L.Layer> = {};
7777
title: 'Gelände Tirol: Oberflächenmodell',
7878
},
7979
].forEach(({id, title}) => {
80-
const layer = L.tileLayer.wms(
80+
const layer = new TileLayer.WMS(
8181
'https://gis.tirol.gv.at/arcgis/services/Service_Public/terrain/MapServer/WMSServer',
8282
{
8383
layers: id,
@@ -107,7 +107,7 @@ const allMapLayers: Record<string, L.Layer> = {};
107107
title: 'Orthofoto Tirol: <abbr title="photographisches Infrarot">CIR</abbr> aktuell',
108108
},
109109
].forEach(({id, title}) => {
110-
const layer = L.tileLayer.wms(
110+
const layer = new TileLayer.WMS(
111111
'https://gis.tirol.gv.at/arcgis/services/Service_Public/orthofoto/MapServer/WMSServer',
112112
{
113113
layers: id,
@@ -127,7 +127,7 @@ const allMapLayers: Record<string, L.Layer> = {};
127127
{id: 'bmaporthofoto30cm/normal', title: 'basemap.at Orthofoto', format: 'jpg'},
128128
{id: 'bmapgelaende/grau', title: 'basemap.at Gelände', format: 'jpg'},
129129
].forEach(({id, title, format}) => {
130-
const layer = L.tileLayer(
130+
const layer = new TileLayer(
131131
`https://mapsneu.wien.gv.at/basemap/${id}/google3857/{z}/{y}/{x}.${format}`,
132132
{
133133
subdomains: '1234',
@@ -143,7 +143,7 @@ const allMapLayers: Record<string, L.Layer> = {};
143143
});
144144

145145
[{id: 'p_bz-BaseMap%3ABasemap-Standard', title: 'South Tyrol Base Map'}].forEach(({id, title}) => {
146-
const layer = L.tileLayer(
146+
const layer = new TileLayer(
147147
`https://geoservices.buergernetz.bz.it/geoserver/gwc/service/wmts/?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${id}&STYLE=default&TILEMATRIXSET=GoogleMapsCompatible&TILEMATRIX=GoogleMapsCompatible%3A{z}&TILEROW={y}&TILECOL={x}&FORMAT=image%2Fjpeg`,
148148
{
149149
maxZoom: 20,
@@ -175,7 +175,7 @@ const allMapLayers: Record<string, L.Layer> = {};
175175
// Slope/Hangneigung/Clivometria
176176
},
177177
].forEach(({id, title}) => {
178-
const layer = L.tileLayer.wms('https://geoservices1.civis.bz.it/geoserver/p_bz-Elevation/wms', {
178+
const layer = new TileLayer.WMS('https://geoservices1.civis.bz.it/geoserver/p_bz-Elevation/wms', {
179179
layers: id,
180180
format: 'image/jpeg',
181181
attribution: attributionST_CC0.join(', '),
@@ -204,7 +204,7 @@ const allMapLayers: Record<string, L.Layer> = {};
204204
title: 'Orthofoto South Tyrol: 2023 <abbr title="photographisches Infrarot">CIR</abbr>',
205205
},
206206
].forEach(({id, title}) => {
207-
const layer = L.tileLayer.wms(
207+
const layer = new TileLayer.WMS(
208208
'https://geoservices.buergernetz.bz.it/mapproxy/p_bz-Orthoimagery/wms',
209209
{
210210
layers: id,
@@ -217,13 +217,13 @@ const allMapLayers: Record<string, L.Layer> = {};
217217
allMapLayers[id] = layer;
218218
});
219219

220-
allMapLayers['OSM'] = L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
220+
allMapLayers['OSM'] = new TileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
221221
maxZoom: 19,
222222
attribution: attributionOsm,
223223
});
224224
layers.addBaseLayer(allMapLayers['OSM'], 'OpenStreetMap');
225225

226-
allMapLayers['OpenTopoMap'] = L.tileLayer('https://tile.opentopomap.org/{z}/{x}/{y}.png', {
226+
allMapLayers['OpenTopoMap'] = new TileLayer('https://tile.opentopomap.org/{z}/{x}/{y}.png', {
227227
maxZoom: 19,
228228
attribution: [
229229
attributionOsm,
@@ -243,7 +243,7 @@ layers.addBaseLayer(allMapLayers['OpenTopoMap'], 'OpenTopoMap');
243243
title: 'Gelände Tirol: Geländeneigung',
244244
},
245245
].forEach(({id, title}) => {
246-
const layer = L.tileLayer.wms(
246+
const layer = new TileLayer.WMS(
247247
'https://gis.tirol.gv.at/arcgis/services/Service_Public/terrain/MapServer/WMSServer',
248248
{
249249
layers: id,
@@ -259,7 +259,7 @@ layers.addBaseLayer(allMapLayers['OpenTopoMap'], 'OpenTopoMap');
259259
allMapLayers[id] = layer;
260260
});
261261

262-
allMapLayers['OpenSlopeMap'] = L.tileLayer(
262+
allMapLayers['OpenSlopeMap'] = new TileLayer(
263263
'https://tileserver{s}.openslopemap.org/OSloOVERLAY_LR_All_16/{z}/{x}/{y}.png',
264264
{
265265
opacity: 0.7,

src/leaflet-fullHash.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// slightly modified version of https://github.com/KoGor/leaflet-fullHash by "KoGor"
2-
import * as L from 'leaflet';
2+
import {LatLng, Util} from 'leaflet';
33

44
export default class LeafletHash {
55
map: L.Map = null;
@@ -10,7 +10,7 @@ export default class LeafletHash {
1010
changeTimeout = null;
1111
isListening = false;
1212
constructor(map: L.Map, options: Record<string, L.Layer>) {
13-
this.onHashChange = L.Util.bind(this.onHashChange, this);
13+
this.onHashChange = this.onHashChange.bind(this);
1414
if (map) {
1515
this.init(map, options);
1616
}
@@ -30,7 +30,7 @@ export default class LeafletHash {
3030
return false;
3131
} else {
3232
return {
33-
center: new L.LatLng(lat, lon),
33+
center: new LatLng(lat, lon),
3434
zoom: zoom,
3535
layers: layers,
3636
};
@@ -64,7 +64,7 @@ export default class LeafletHash {
6464

6565
init(map: L.Map, options: Record<string, L.Layer>) {
6666
this.map = map;
67-
L.Util.setOptions(this, options);
67+
Util.setOptions(this, options);
6868

6969
// reset the hash
7070
this.lastHash = null;
@@ -114,8 +114,7 @@ export default class LeafletHash {
114114
this.map.setView(parsed.center, parsed.zoom);
115115
const layers = parsed.layers;
116116
const options = this.options;
117-
console.log(layers);
118-
//Add/remove layers
117+
119118
if (Array.isArray(layers) && layers.every((l) => options[l])) {
120119
this.map.eachLayer((layer) => this.map.removeLayer(layer));
121120
layers.forEach((l) => this.map.addLayer(options[l]));

yarn.lock

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,16 @@ __metadata:
377377
languageName: node
378378
linkType: hard
379379

380-
"@types/leaflet.locatecontrol@npm:^0.74.6":
381-
version: 0.74.6
382-
resolution: "@types/leaflet.locatecontrol@npm:0.74.6"
380+
"@types/leaflet.locatecontrol@npm:^0.82.0":
381+
version: 0.82.0
382+
resolution: "@types/leaflet.locatecontrol@npm:0.82.0"
383383
dependencies:
384384
"@types/leaflet": "npm:*"
385-
checksum: 10c0/4969ee6238ed797f4a269d9b603af9fc78d49ecd1ce8f074b996010ae3658030569aeca028d9c210b97095f97bd2acf7b6bc39bdbb507b6b186eb46fc8c7c5b7
385+
checksum: 10c0/4bd0337016998d4753397ca0db04b1f9207d5d8caa1092169c80af5389e7ea58b1054a0de5d9d794e6a11e681379d8d9ec9b547625d4cc9239c0fd1a837c7ea3
386386
languageName: node
387387
linkType: hard
388388

389-
"@types/leaflet@npm:*, @types/leaflet@npm:^1.9.15":
389+
"@types/leaflet@npm:*":
390390
version: 1.9.15
391391
resolution: "@types/leaflet@npm:1.9.15"
392392
dependencies:
@@ -395,6 +395,15 @@ __metadata:
395395
languageName: node
396396
linkType: hard
397397

398+
"@types/leaflet@npm:^1.9.18":
399+
version: 1.9.18
400+
resolution: "@types/leaflet@npm:1.9.18"
401+
dependencies:
402+
"@types/geojson": "npm:*"
403+
checksum: 10c0/376ef5b5d60664e8cc22908a75149c020ad668330ef61f0e7486a61e85285b3f1b9dafcce9462bd3375be537e4d1227fc0c0524e5c071a4a45ed16bf3fc71608
404+
languageName: node
405+
linkType: hard
406+
398407
"abbrev@npm:^2.0.0":
399408
version: 2.0.0
400409
resolution: "abbrev@npm:2.0.0"
@@ -884,31 +893,33 @@ __metadata:
884893
languageName: node
885894
linkType: hard
886895

887-
"leaflet-control-geocoder@npm:^3.1.0":
888-
version: 3.1.0
889-
resolution: "leaflet-control-geocoder@npm:3.1.0"
896+
"leaflet-control-geocoder@npm:^3.2.0":
897+
version: 3.2.0
898+
resolution: "leaflet-control-geocoder@npm:3.2.0"
890899
dependencies:
891900
open-location-code: "npm:^1.0.3"
892901
peerDependencies:
893-
leaflet: ^1.6.0
902+
leaflet: ^1.6.0 || ^2.0.0
894903
dependenciesMeta:
895904
open-location-code:
896905
optional: true
897-
checksum: 10c0/fd9c92daca8695b113f80e56540d753196baa74a952f1c99863ba10eab9899813bf63dec935889a49d11a93ace2dcc78170e351510e742f72bf8277a79ba9103
906+
checksum: 10c0/da85af31f8e5bb2760739b1830c847d50cd5c1833b461f0fabe6e39be8a07d351ccdd7b1fb4da1c6550b3f86eabeb5a411f445659cd9260bd1060c8d536f747e
898907
languageName: node
899908
linkType: hard
900909

901-
"leaflet.locatecontrol@npm:^0.83.0":
902-
version: 0.83.0
903-
resolution: "leaflet.locatecontrol@npm:0.83.0"
904-
checksum: 10c0/b03aa0a74bc4af25c54f0167501a18f24e6d91abbca2cb60ca240ca5c5b938d88d84e1866ce91e2b563dc7cad5a8382c86fad2609759a5ecd3f5dd71bd9c8035
910+
"leaflet.locatecontrol@jeffreykog/leaflet-locatecontrol#leaflet-v2":
911+
version: 0.84.2
912+
resolution: "leaflet.locatecontrol@https://github.com/jeffreykog/leaflet-locatecontrol.git#commit=65a477953a6292bc00b55cc86866abbc49e6dcec"
913+
peerDependencies:
914+
leaflet: ^1.9.0 || ^2.0.0
915+
checksum: 10c0/7722dc720015a2efd6963c041ca1717881ded6d926185cb21d5e91a678643d69a1f790c12913b50e3e883a90453bfba952be64b5089c94e05583930a4cb94efb
905916
languageName: node
906917
linkType: hard
907918

908-
"leaflet@npm:^1.9.4":
909-
version: 1.9.4
910-
resolution: "leaflet@npm:1.9.4"
911-
checksum: 10c0/f639441dbb7eb9ae3fcd29ffd7d3508f6c6106892441634b0232fafb9ffb1588b05a8244ec7085de2c98b5ed703894df246898477836cfd0ce5b96d4717b5ca1
919+
"leaflet@npm:2.0.0-alpha":
920+
version: 2.0.0-alpha
921+
resolution: "leaflet@npm:2.0.0-alpha"
922+
checksum: 10c0/38c1c39a3ee919a3392df067b55bab45b5e66cdac6d49d142ac4c04f8fbc8730228fa0408cc4ffe48128f5a2366c4a69d9713d2b5cfcbcc9ea4d2ac5593fb36c
912923
languageName: node
913924
linkType: hard
914925

@@ -1507,11 +1518,11 @@ __metadata:
15071518
version: 0.0.0-use.local
15081519
resolution: "tyrolean-map@workspace:."
15091520
dependencies:
1510-
"@types/leaflet": "npm:^1.9.15"
1511-
"@types/leaflet.locatecontrol": "npm:^0.74.6"
1512-
leaflet: "npm:^1.9.4"
1513-
leaflet-control-geocoder: "npm:^3.1.0"
1514-
leaflet.locatecontrol: "npm:^0.83.0"
1521+
"@types/leaflet": "npm:^1.9.18"
1522+
"@types/leaflet.locatecontrol": "npm:^0.82.0"
1523+
leaflet: "npm:2.0.0-alpha"
1524+
leaflet-control-geocoder: "npm:^3.2.0"
1525+
leaflet.locatecontrol: "jeffreykog/leaflet-locatecontrol#leaflet-v2"
15151526
prettier: "npm:^3.5.3"
15161527
pretty-quick: "npm:^4.1.1"
15171528
vite: "npm:^6.3.2"

0 commit comments

Comments
 (0)