mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Handle map reset when the game is loaded/unloaded.
https://github.com/dcs-liberation/dcs_liberation/issues/2039 Partial fix for https://github.com/dcs-liberation/dcs_liberation/issues/2045 (now works in the new map, old one not fixed yet).
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { selectMapCenter } from "../../api/mapSlice";
|
||||
import { useAppSelector } from "../../app/hooks";
|
||||
import AircraftLayer from "../aircraftlayer";
|
||||
import AirDefenseRangeLayer from "../airdefenserangelayer";
|
||||
import CombatLayer from "../combatlayer";
|
||||
@@ -7,17 +9,23 @@ import FrontLinesLayer from "../frontlineslayer";
|
||||
import SupplyRoutesLayer from "../supplyrouteslayer";
|
||||
import TgosLayer from "../tgoslayer/TgosLayer";
|
||||
import "./LiberationMap.css";
|
||||
import { LatLng } from "leaflet";
|
||||
import { Map } from "leaflet";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { BasemapLayer } from "react-esri-leaflet";
|
||||
import { LayersControl, MapContainer, ScaleControl } from "react-leaflet";
|
||||
|
||||
interface GameProps {
|
||||
mapCenter: LatLng;
|
||||
}
|
||||
|
||||
export default function LiberationMap(props: GameProps) {
|
||||
export default function LiberationMap() {
|
||||
const map = useRef<Map>();
|
||||
const mapCenter = useAppSelector(selectMapCenter);
|
||||
useEffect(() => {
|
||||
map.current?.setView(mapCenter, 8, { animate: true, duration: 1 });
|
||||
});
|
||||
return (
|
||||
<MapContainer zoom={8} center={props.mapCenter} zoomControl={false}>
|
||||
<MapContainer
|
||||
zoom={8}
|
||||
zoomControl={false}
|
||||
whenCreated={(mapInstance) => (map.current = mapInstance)}
|
||||
>
|
||||
<ScaleControl />
|
||||
<LayersControl collapsed={false}>
|
||||
<LayersControl.BaseLayer name="Imagery Clarity" checked>
|
||||
|
||||
Reference in New Issue
Block a user