forked from MapComplete/MapComplete
Lot's of small improvements
This commit is contained in:
parent
9bd37d9cde
commit
8bca006787
29 changed files with 375 additions and 173 deletions
|
@ -1,5 +1,6 @@
|
|||
import L from "leaflet"
|
||||
import {UIEventSource} from "../UI/UIEventSource";
|
||||
import {UIElement} from "../UI/UIElement";
|
||||
|
||||
// Contains all setup and baselayers for Leaflet stuff
|
||||
export class Basemap {
|
||||
|
@ -8,6 +9,7 @@ export class Basemap {
|
|||
public map: Map;
|
||||
|
||||
public Location: UIEventSource<{ zoom: number, lat: number, lon: number }>;
|
||||
public LastClickLocation: UIEventSource<{ lat: number, lon: number }> = new UIEventSource<{lat: number, lon: number}>(undefined)
|
||||
|
||||
private aivLucht2013Layer = L.tileLayer.wms('https://geoservices.informatievlaanderen.be/raadpleegdiensten/OGW/wms?s',
|
||||
{
|
||||
|
@ -19,7 +21,7 @@ export class Basemap {
|
|||
"LAYER=omwrgbmrvl&STYLE=&FORMAT=image/png&tileMatrixSet=GoogleMapsVL&tileMatrix={z}&tileRow={y}&tileCol={x}",
|
||||
{
|
||||
// omwrgbmrvl
|
||||
attribution: 'Map Data <a href="osm.org">OpenStreetMap</a> | Luchtfoto\'s van © AIV Vlaanderen (Laatste) © AGIV',
|
||||
attribution: 'Map Data <a href="https://osm.org">OpenStreetMap</a> | Luchtfoto\'s van © AIV Vlaanderen (Laatste) © AGIV',
|
||||
maxZoom: 20,
|
||||
minZoom: 1,
|
||||
wmts: true
|
||||
|
@ -28,20 +30,20 @@ export class Basemap {
|
|||
|
||||
private osmLayer = L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||
{
|
||||
attribution: 'Map Data and background © <a href="osm.org">OpenStreetMap</a>',
|
||||
attribution: 'Map Data and background © <a href="https://osm.org">OpenStreetMap</a>',
|
||||
maxZoom: 19,
|
||||
minZoom: 1
|
||||
});
|
||||
private osmBeLayer = L.tileLayer("https://tile.osm.be/osmbe/{z}/{x}/{y}.png",
|
||||
{
|
||||
attribution: 'Map Data and background © <a href="osm.org">OpenStreetMap</a> | <a href="https://geo6.be/">Tiles courtesy of Geo6</a>',
|
||||
attribution: 'Map Data and background © <a href="https://osm.org">OpenStreetMap</a> | <a href="https://geo6.be/">Tiles courtesy of Geo6</a>',
|
||||
maxZoom: 18,
|
||||
minZoom: 1
|
||||
});
|
||||
|
||||
private grbLayer = 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: 'Map Data <a href="osm.org">OpenStreetMap</a> | Background <i>Grootschalig ReferentieBestand</i>(GRB) © AGIV',
|
||||
attribution: 'Map Data <a href="https://osm.org">OpenStreetMap</a> | Background <i>Grootschalig ReferentieBestand</i>(GRB) © AGIV',
|
||||
maxZoom: 20,
|
||||
minZoom: 1,
|
||||
wmts: true
|
||||
|
@ -56,25 +58,24 @@ export class Basemap {
|
|||
"GRB Vlaanderen": this.grbLayer
|
||||
};
|
||||
|
||||
|
||||
constructor(leafletElementId: string, location: UIEventSource<{ zoom: number, lat: number, lon: number }>) {
|
||||
constructor(leafletElementId: string,
|
||||
location: UIEventSource<{ zoom: number, lat: number, lon: number }>,
|
||||
extraAttribution: UIElement) {
|
||||
this.map = L.map(leafletElementId, {
|
||||
center: [location.data.lat, location.data.lon],
|
||||
zoom: location.data.zoom,
|
||||
layers: [this.osmLayer],
|
||||
});
|
||||
|
||||
|
||||
this.map.attributionControl.setPrefix(extraAttribution.Render());
|
||||
this.Location = location;
|
||||
|
||||
const layerControl = L.control.layers(this.baseLayers, null,
|
||||
{
|
||||
position: 'bottomright',
|
||||
hideSingleBase: true
|
||||
})
|
||||
layerControl.addTo(this.map);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.map.zoomControl.setPosition("bottomright");
|
||||
const self = this;
|
||||
|
@ -82,11 +83,13 @@ export class Basemap {
|
|||
this.map.on("moveend", function () {
|
||||
location.data.zoom = self.map.getZoom();
|
||||
location.data.lat = self.map.getCenter().lat;
|
||||
location.data.lon = self.map.getCenter().lon;
|
||||
location.data.lon = self.map.getCenter().lng;
|
||||
location.ping();
|
||||
});
|
||||
|
||||
|
||||
this.map.on("click", function (e) {
|
||||
self.LastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue