Pan on marker click

This commit is contained in:
James Lyne 2021-05-25 23:31:03 +01:00
parent 36a2d483ff
commit e3233e3dfa

View File

@ -17,7 +17,7 @@
* limitations under the License.
*/
import {Marker} from "leaflet";
import {LeafletMouseEvent, Marker} from "leaflet";
import {DynmapMarker} from "@/dynmap";
import {DynmapIcon} from "@/leaflet/icon/DynmapIcon";
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
@ -35,6 +35,10 @@ export const createMarker = (options: DynmapMarker, projection: DynmapProjection
minZoom: options.minZoom,
});
marker.on('click', (e: LeafletMouseEvent) => {
e.target._map.panTo(e.target.getLatLng());
});
if(options.popupContent) {
marker.bindPopup(() => createPopup(options));
}