add panTo-method to center view on marker-click

This commit is contained in:
Tim Herbst 2020-12-27 15:46:43 +01:00
parent b484857746
commit 9afb135d91

View File

@ -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) => {