Merge branch 'main' of https://git.olemenke.com/Ol86/HKA-OSM
This commit is contained in:
@@ -1,8 +1,15 @@
|
|||||||
<div class="map-wrapper">
|
<div class="map-wrapper">
|
||||||
<div
|
<div
|
||||||
class="map-container"
|
class="map-container"
|
||||||
|
[ngClass]="isFullscreen ? 'map-fullscreen' : 'map-details'"
|
||||||
leaflet
|
leaflet
|
||||||
[leafletOptions]="options"
|
[leafletOptions]="options"
|
||||||
(leafletMapReady)="onMapReady($event)"
|
(leafletMapReady)="onMapReady($event)"
|
||||||
></div>
|
></div>
|
||||||
|
@if (!isFullscreen && details) {
|
||||||
|
<div class="details">
|
||||||
|
<h2>{{ details.name }}</h2>
|
||||||
|
<p>{{ details.building }}</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
.map-container {
|
.map-container {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: 54px;
|
top: 54px;
|
||||||
height: calc(100vh - 54px);
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,14 +13,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.map-details {
|
.map-details {
|
||||||
left: 10%;
|
left: 25%;
|
||||||
width: 90%;
|
width: 75%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.details {
|
.details {
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: 54px;
|
top: 54px;
|
||||||
left: 0;
|
left: 25px;
|
||||||
width: 10%;
|
width: 25%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, signal } from '@angular/core';
|
import { Component, signal, OnInit, ChangeDetectorRef } from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { LeafletModule } from '@bluehalo/ngx-leaflet';
|
import { LeafletModule } from '@bluehalo/ngx-leaflet';
|
||||||
import { center } from '@turf/turf';
|
import { center } from '@turf/turf';
|
||||||
@@ -14,15 +14,26 @@ import * as E from './geojson';
|
|||||||
templateUrl: './map.html',
|
templateUrl: './map.html',
|
||||||
styleUrl: './map.scss',
|
styleUrl: './map.scss',
|
||||||
})
|
})
|
||||||
export class OSMMap {
|
export class OSMMap implements OnInit {
|
||||||
private buildingLayer?: L.LayerGroup;
|
private buildingLayer?: L.LayerGroup;
|
||||||
|
|
||||||
protected readonly title = signal('HKA-OSM');
|
protected readonly title = signal('HKA-OSM');
|
||||||
map?: L.Map;
|
map?: L.Map;
|
||||||
|
details?: D.Details;
|
||||||
|
|
||||||
|
osm?: L.TileLayer;
|
||||||
|
options: L.MapOptions = {};
|
||||||
|
layerControl?: L.Control.Layers;
|
||||||
|
|
||||||
isFullscreen = true;
|
isFullscreen = true;
|
||||||
|
|
||||||
osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
constructor(
|
||||||
|
private overpass: Overpass,
|
||||||
|
private cdr: ChangeDetectorRef
|
||||||
|
) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
maxNativeZoom: 19,
|
maxNativeZoom: 19,
|
||||||
maxZoom: 21,
|
maxZoom: 21,
|
||||||
minZoom: 18,
|
minZoom: 18,
|
||||||
@@ -30,7 +41,7 @@ export class OSMMap {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Define map options
|
// Define map options
|
||||||
options: L.MapOptions = {
|
this.options = {
|
||||||
layers: [this.osm],
|
layers: [this.osm],
|
||||||
zoom: 18, // Zoom level
|
zoom: 18, // Zoom level
|
||||||
center: this.getCenter(), // Center of the map
|
center: this.getCenter(), // Center of the map
|
||||||
@@ -41,15 +52,14 @@ export class OSMMap {
|
|||||||
maxBoundsViscosity: 1.0, // Prevent panning outside bounds
|
maxBoundsViscosity: 1.0, // Prevent panning outside bounds
|
||||||
};
|
};
|
||||||
|
|
||||||
layerControl = L.control.layers({
|
this.layerControl = L.control.layers({
|
||||||
OpenStreetMap: this.osm,
|
OpenStreetMap: this.osm,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
constructor(private overpass: Overpass) {}
|
|
||||||
|
|
||||||
onMapReady(map: L.Map) {
|
onMapReady(map: L.Map) {
|
||||||
this.map = map;
|
this.map = map;
|
||||||
this.layerControl.addTo(this.map);
|
this.layerControl?.addTo(this.map);
|
||||||
this.loadBuildings().addTo(this.map);
|
this.loadBuildings().addTo(this.map);
|
||||||
console.log('Map is ready');
|
console.log('Map is ready');
|
||||||
}
|
}
|
||||||
@@ -65,6 +75,7 @@ export class OSMMap {
|
|||||||
this.map?.setView(this.getCenter(feature.geometry), 20);
|
this.map?.setView(this.getCenter(feature.geometry), 20);
|
||||||
this.buildingLayer = this.queryBuildings(feature.properties.name);
|
this.buildingLayer = this.queryBuildings(feature.properties.name);
|
||||||
this.buildingLayer.addTo(this.map!);
|
this.buildingLayer.addTo(this.map!);
|
||||||
|
this.details = new D.Details(feature.properties.name, feature.properties.building)
|
||||||
} else {
|
} else {
|
||||||
this.map?.setView(this.getCenter(), 18);
|
this.map?.setView(this.getCenter(), 18);
|
||||||
if (this.buildingLayer) {
|
if (this.buildingLayer) {
|
||||||
@@ -73,6 +84,7 @@ export class OSMMap {
|
|||||||
}
|
}
|
||||||
console.log('Set isFullscreen to:', this.isFullscreen);
|
console.log('Set isFullscreen to:', this.isFullscreen);
|
||||||
console.log('Clicked on feature:', feature.properties?.name);
|
console.log('Clicked on feature:', feature.properties?.name);
|
||||||
|
this.cdr.detectChanges();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (feature.properties && feature.properties.name) {
|
if (feature.properties && feature.properties.name) {
|
||||||
|
|||||||
Reference in New Issue
Block a user