add panTo-method to center view on marker-click
This commit is contained in:
parent
b484857746
commit
9afb135d91
@ -63,10 +63,11 @@ export class MapService {
|
|||||||
for (const station of data) {
|
for (const station of data) {
|
||||||
const marker = L.marker([station.lat, station.lon], {icon: createIcon});
|
const marker = L.marker([station.lat, station.lon], {icon: createIcon});
|
||||||
markerClusters.addLayer(marker);
|
markerClusters.addLayer(marker);
|
||||||
marker.on('click', e => e.target
|
marker.on('click', e => {
|
||||||
.bindPopup(this.popUpService.makeAvailabilityPopUp(station), {maxWidth: 'auto'})
|
e.target.bindPopup(this.popUpService.makeAvailabilityPopUp(station), {maxWidth: 'auto'})
|
||||||
.openPopup()
|
.openPopup();
|
||||||
);
|
this.map.panTo(e.target.getLatLng());
|
||||||
|
});
|
||||||
marker.on('popupclose', e => e.target.unbindPopup());
|
marker.on('popupclose', e => e.target.unbindPopup());
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user