| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | import L from "leaflet" | 
					
						
							|  |  |  | import {UIEventSource} from "../UI/UIEventSource"; | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  | import {UIElement} from "../UI/UIElement"; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Contains all setup and baselayers for Leaflet stuff
 | 
					
						
							|  |  |  | export class Basemap { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // @ts-ignore
 | 
					
						
							|  |  |  |     public map: Map; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public Location: UIEventSource<{ zoom: number, lat: number, lon: number }>; | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  |     public LastClickLocation: UIEventSource<{ lat: number, lon: number }> = new UIEventSource<{lat: number, lon: number}>(undefined) | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private aivLucht2013Layer = L.tileLayer.wms('https://geoservices.informatievlaanderen.be/raadpleegdiensten/OGW/wms?s', | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             layers: "OGWRGB13_15VL", | 
					
						
							| 
									
										
										
										
											2020-06-29 03:40:19 +02:00
										 |  |  |             attribution: "Luchtfoto's van © AIV Vlaanderen (2013-2015) | " | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private aivLuchtLatestLayer = 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
 | 
					
						
							| 
									
										
										
										
											2020-06-29 03:40:19 +02:00
										 |  |  |             attribution: 'Luchtfoto\'s van © AIV Vlaanderen (Laatste)  © AGIV', | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             maxZoom: 20, | 
					
						
							|  |  |  |             minZoom: 1, | 
					
						
							|  |  |  |             wmts: true | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private osmLayer = L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-06-29 03:40:19 +02:00
										 |  |  |             attribution: '', | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             maxZoom: 19, | 
					
						
							|  |  |  |             minZoom: 1 | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     private osmBeLayer = L.tileLayer("https://tile.osm.be/osmbe/{z}/{x}/{y}.png", | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-06-29 03:40:19 +02:00
										 |  |  |             attribution: '<a href="https://geo6.be/">Tile hosting courtesy of Geo6</a>', | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             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}", | 
					
						
							|  |  |  |         { | 
					
						
							| 
									
										
										
										
											2020-06-29 03:40:19 +02:00
										 |  |  |             attribution: 'Achtergrond <i>Grootschalig ReferentieBestand</i>(GRB) © AGIV', | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             maxZoom: 20, | 
					
						
							|  |  |  |             minZoom: 1, | 
					
						
							|  |  |  |             wmts: true | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private baseLayers = { | 
					
						
							| 
									
										
										
										
											2020-07-05 18:59:47 +02:00
										 |  |  |         "Luchtfoto Vlaanderen (recentste door AIV)": this.aivLuchtLatestLayer, | 
					
						
							|  |  |  |         "Luchtfoto Vlaanderen (2013-2015, door AIV)": this.aivLucht2013Layer, | 
					
						
							|  |  |  |         "Kaart van OpenStreetMap": this.osmLayer, | 
					
						
							|  |  |  |         "Kaart Grootschalig ReferentieBestand Vlaanderen (GRB) door AIV": this.grbLayer | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  |     constructor(leafletElementId: string, | 
					
						
							|  |  |  |                 location: UIEventSource<{ zoom: number, lat: number, lon: number }>, | 
					
						
							|  |  |  |                 extraAttribution: UIElement) { | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  |         this.map = L.map(leafletElementId, { | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             center: [location.data.lat, location.data.lon], | 
					
						
							|  |  |  |             zoom: location.data.zoom, | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  |             layers: [this.osmLayer], | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-06-29 03:40:19 +02:00
										 |  |  |         this.map.attributionControl.setPrefix( | 
					
						
							|  |  |  |             extraAttribution.Render() + " | <a href='https://osm.org'>OpenStreetMap</a>"); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         this.Location = location; | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  |         const layerControl = L.control.layers(this.baseLayers, null, | 
					
						
							|  |  |  |             { | 
					
						
							| 
									
										
										
										
											2020-06-28 00:06:23 +02:00
										 |  |  |                 position: 'bottomright', | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  |                 hideSingleBase: true | 
					
						
							|  |  |  |             }) | 
					
						
							|  |  |  |         layerControl.addTo(this.map); | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-28 00:06:23 +02:00
										 |  |  |         this.map.zoomControl.setPosition("bottomright"); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         const self = this; | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |         this.map.on("moveend", function () { | 
					
						
							|  |  |  |             location.data.zoom = self.map.getZoom(); | 
					
						
							|  |  |  |             location.data.lat = self.map.getCenter().lat; | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  |             location.data.lon = self.map.getCenter().lng; | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |             location.ping(); | 
					
						
							| 
									
										
										
										
											2020-06-27 03:06:51 +02:00
										 |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-29 03:12:44 +02:00
										 |  |  |         this.map.on("click", function (e) { | 
					
						
							|  |  |  |             self.LastClickLocation.setData({lat: e.latlng.lat, lon: e.latlng.lng}) | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2020-06-24 00:35:19 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |