Prevent zooming out too much & prevent dragging the map out of bound

pull/1/head
Alix JEUDI--LEMOINE 5 months ago
parent c33d62deaf
commit cbff358bc5

@ -19,7 +19,14 @@ export class LeafletMapComponent implements OnInit {
private initializeMap(): void {
// Initialize the map
this.map = L.map('map').setView([46.603354, 1.888334], 6);
this.map = L.map('map', {
maxBounds: L.latLngBounds(
L.latLng(-90, -180), // South-West
L.latLng(90, 180) // North-East
),
maxBoundsViscosity: 1.0, // Prevent dragging the map out of bounds
minZoom: 2, // Prevent zooming out too much
}).setView([46.603354, 1.888334], 6);
// Add OpenStreetMap tiles
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {

Loading…
Cancel
Save