Pan on marker click
This commit is contained in:
parent
36a2d483ff
commit
e3233e3dfa
@ -17,7 +17,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Marker} from "leaflet";
|
import {LeafletMouseEvent, Marker} from "leaflet";
|
||||||
import {DynmapMarker} from "@/dynmap";
|
import {DynmapMarker} from "@/dynmap";
|
||||||
import {DynmapIcon} from "@/leaflet/icon/DynmapIcon";
|
import {DynmapIcon} from "@/leaflet/icon/DynmapIcon";
|
||||||
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
|
import {DynmapProjection} from "@/leaflet/projection/DynmapProjection";
|
||||||
@ -35,6 +35,10 @@ export const createMarker = (options: DynmapMarker, projection: DynmapProjection
|
|||||||
minZoom: options.minZoom,
|
minZoom: options.minZoom,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
marker.on('click', (e: LeafletMouseEvent) => {
|
||||||
|
e.target._map.panTo(e.target.getLatLng());
|
||||||
|
});
|
||||||
|
|
||||||
if(options.popupContent) {
|
if(options.popupContent) {
|
||||||
marker.bindPopup(() => createPopup(options));
|
marker.bindPopup(() => createPopup(options));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user