Reputation: 17
I'm initializing a map using leaflet(openstreetmaps) in angular and setting a center that the user sees when opening the site. How can i change the center so the map rotates to the new coordinates on click of e.g. a button? Setting a new center doesn't appear to do anything, neither do i want to reload the site itself. Thanks!
private initMap(): void {
this.map = L.map('map', {
center: [48.1841234, 11.5877796],
zoom: 16
});}
Upvotes: 0
Views: 1809
Reputation: 11338
you can use map.flyTo([latlng])
or map.panTo([latlng])
https://leafletjs.com/reference-1.6.0.html#map-panto
Upvotes: 1