forked from MapComplete/MapComplete
First attempt to get the editor-layer-index working
This commit is contained in:
parent
e46ea51d44
commit
08175a747f
11 changed files with 268 additions and 74 deletions
|
@ -5,54 +5,46 @@ import {UIElement} from "../../UI/UIElement";
|
|||
|
||||
export class BaseLayers {
|
||||
|
||||
public static readonly defaultLayer: { name: string, layer: any, id: string } = {
|
||||
id: "osm",
|
||||
name: "Kaart van OpenStreetMap", layer: L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
{
|
||||
attribution: '',
|
||||
maxZoom: 19,
|
||||
minZoom: 1
|
||||
})
|
||||
};
|
||||
public static readonly baseLayers: { name: string, layer: any, id: string } [] = [
|
||||
|
||||
{
|
||||
id: "aiv-latest",
|
||||
name: "Luchtfoto Vlaanderen (recentste door AIV)",
|
||||
layer: L.tileLayer("https://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&" +
|
||||
"LAYER=omwrgbmrvl&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileRow={y}&tileCol={x}",
|
||||
{
|
||||
// omwrgbmrvl
|
||||
attribution: 'Luchtfoto\'s van © AIV Vlaanderen (Laatste) © AGIV',
|
||||
maxZoom: 22,
|
||||
minZoom: 1,
|
||||
wmts: true
|
||||
})
|
||||
},
|
||||
BaseLayers.defaultLayer,
|
||||
{
|
||||
id: "aiv-13-15",
|
||||
name: "Luchtfoto Vlaanderen (2013-2015, door AIV)",
|
||||
layer: L.tileLayer.wms('https://geoservices.informatievlaanderen.be/raadpleegdiensten/OGW/wms?s',
|
||||
{
|
||||
maxZoom: 22,
|
||||
layers: "OGWRGB13_15VL",
|
||||
attribution: "Luchtfoto's van © AIV Vlaanderen (2013-2015) | "
|
||||
})
|
||||
},
|
||||
{
|
||||
id:"grb",
|
||||
name: "Kaart Grootschalig ReferentieBestand Vlaanderen (GRB) door AIV",
|
||||
layer: L.tileLayer("https://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=grb_bsk&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileCol={x}&tileRow={y}",
|
||||
{
|
||||
attribution: 'Achtergrond <i>Grootschalig ReferentieBestand</i>(GRB) © AGIV',
|
||||
maxZoom: 22,
|
||||
minZoom: 1,
|
||||
wmts: true
|
||||
})
|
||||
}
|
||||
]
|
||||
;
|
||||
/*public static readonly baseLayers: { name: string, layer: any, id: string } [] = [
|
||||
|
||||
{
|
||||
id: "aiv-latest",
|
||||
name: "Luchtfoto Vlaanderen (recentste door AIV)",
|
||||
layer: L.tileLayer("https://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&" +
|
||||
"LAYER=omwrgbmrvl&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileRow={y}&tileCol={x}",
|
||||
{
|
||||
// omwrgbmrvl
|
||||
attribution: 'Luchtfoto\'s van © AIV Vlaanderen (Laatste) © AGIV',
|
||||
maxZoom: 22,
|
||||
minZoom: 1,
|
||||
wmts: true
|
||||
})
|
||||
},
|
||||
BaseLayers.defaultLayer,
|
||||
{
|
||||
id: "aiv-13-15",
|
||||
name: "Luchtfoto Vlaanderen (2013-2015, door AIV)",
|
||||
layer: L.tileLayer.wms('https://geoservices.informatievlaanderen.be/raadpleegdiensten/OGW/wms?s',
|
||||
{
|
||||
maxZoom: 22,
|
||||
layers: "OGWRGB13_15VL",
|
||||
attribution: "Luchtfoto's van © AIV Vlaanderen (2013-2015) | "
|
||||
})
|
||||
},
|
||||
{
|
||||
id:"grb",
|
||||
name: "Kaart Grootschalig ReferentieBestand Vlaanderen (GRB) door AIV",
|
||||
layer: L.tileLayer("https://tile.informatievlaanderen.be/ws/raadpleegdiensten/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=grb_bsk&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileCol={x}&tileRow={y}",
|
||||
{
|
||||
attribution: 'Achtergrond <i>Grootschalig ReferentieBestand</i>(GRB) © AGIV',
|
||||
maxZoom: 22,
|
||||
minZoom: 1,
|
||||
wmts: true
|
||||
})
|
||||
}
|
||||
]
|
||||
;*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,26 +52,32 @@ export class BaseLayers {
|
|||
export class Basemap {
|
||||
|
||||
|
||||
public static readonly defaultLayer: { name: string, layer: any, id: string } =
|
||||
Basemap.CreateBackgroundLayer("osm", "OpenStreetMap", "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
"<a href='https://openstreetmap.org/copyright' target='_blank'>OpenStreetMap (ODBL)</a>",
|
||||
22, false);
|
||||
|
||||
// @ts-ignore
|
||||
public readonly map: Map;
|
||||
|
||||
public readonly Location: UIEventSource<{ zoom: number, lat: number, lon: number }>;
|
||||
public readonly LastClickLocation: UIEventSource<{ lat: number, lon: number }> = new UIEventSource<{ lat: number, lon: number }>(undefined)
|
||||
private _previousLayer: L.tileLayer = undefined;
|
||||
private _previousLayer: L.tileLayer = undefined;
|
||||
public readonly CurrentLayer: UIEventSource<{
|
||||
id: string,
|
||||
name: string,
|
||||
layer: L.tileLayer
|
||||
}> = new UIEventSource<L.tileLayer>(BaseLayers.defaultLayer);
|
||||
}> = new UIEventSource<L.tileLayer>(Basemap.defaultLayer);
|
||||
|
||||
|
||||
constructor(leafletElementId: string,
|
||||
location: UIEventSource<{ zoom: number, lat: number, lon: number }>,
|
||||
extraAttribution: UIElement) {
|
||||
this._previousLayer = Basemap.defaultLayer.layer;
|
||||
this.map = L.map(leafletElementId, {
|
||||
center: [location.data.lat ?? 0, location.data.lon ?? 0],
|
||||
zoom: location.data.zoom ?? 2,
|
||||
layers: [BaseLayers.defaultLayer.layer],
|
||||
layers: [this._previousLayer],
|
||||
});
|
||||
|
||||
|
||||
|
@ -118,9 +116,43 @@ export class Basemap {
|
|||
|
||||
this.map.on("contextmenu", function (e) {
|
||||
self.LastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng});
|
||||
console.log("Right click")
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static CreateBackgroundLayer(id: string, name: string, url: string, attribution: string,
|
||||
maxZoom: number, isWms: boolean, isWMTS?: boolean) {
|
||||
|
||||
url = url.replace("{zoom}", "{z}")
|
||||
.replace("{switch:", "{")
|
||||
.replace("{proj}", "EPSG:3857")
|
||||
.replace("{width}", "256")
|
||||
.replace("{height}", "256")
|
||||
|
||||
//geoservices.informatievlaanderen.be/raadpleegdiensten/dhmv/wms?FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&LAYERS=DHMV_II_SVF_25cm&STYLES=&SRS=EPSG:3857&WIDTH=256&HEIGHT=256
|
||||
if (isWms) {
|
||||
return {
|
||||
id: id,
|
||||
name: name,
|
||||
layer: L.tileLayer.wms(url,
|
||||
{
|
||||
maxZoom: maxZoom ?? 19,
|
||||
attribution: attribution + " | "
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: id,
|
||||
name: name,
|
||||
layer: L.tileLayer(url,
|
||||
{
|
||||
attribution: attribution,
|
||||
maxZoom: maxZoom,
|
||||
minZoom: 1,
|
||||
wmts: isWMTS ?? false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue