diff --git a/projects/project-3/frontend/src/app/service/map.service.ts b/projects/project-3/frontend/src/app/service/map.service.ts index 26738d7..d49ed23 100644 --- a/projects/project-3/frontend/src/app/service/map.service.ts +++ b/projects/project-3/frontend/src/app/service/map.service.ts @@ -63,10 +63,11 @@ export class MapService { for (const station of data) { const marker = L.marker([station.lat, station.lon], {icon: createIcon}); markerClusters.addLayer(marker); - marker.on('click', e => e.target - .bindPopup(this.popUpService.makeAvailabilityPopUp(station), {maxWidth: 'auto'}) - .openPopup() - ); + marker.on('click', e => { + e.target.bindPopup(this.popUpService.makeAvailabilityPopUp(station), {maxWidth: 'auto'}) + .openPopup(); + this.map.panTo(e.target.getLatLng()); + }); marker.on('popupclose', e => e.target.unbindPopup()); } }).catch((error) => {