import { MapContainer, TileLayer, useMap, Polyline } from 'react-leaflet'
export const GeographicView = (props) => {
const SetHeightOnChange = ({ height }) => {
const map = useMap();
useEffect(() => {
if (map != null) {
map.invalidateSize();
}
}, [map, height]);
const mapContainer = map.getContainer();
mapContainer.style.cssText = `height: ${height}; width: 100%; position: relative;`;
return null;
}
return (
<MapContainer
style={{ height: props.height || "80vh", width: "100%" }}
center={props.centroid}
zoom={8}
scrollWheelZoom={false}
>
<SetHeightOnChange height={props.height || "80vh"} />
<TileLayer
attribution="Google Maps Satellite"
url="https://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}"
/>
<Polyline
key={index}
positions={props.shape.vertices}
pathOptions={{
color: legend.find(item => item.value === props.shape.legend)?.color || "blue",
}}
/>
</MapContainer>
)
}
import { MapContainer, TileLayer, useMap, Polyline } from 'react-leaflet'
export const GeographicView = (props) => {
const SetHeightOnChange = ({ height }) => {
const map = useMap();
useEffect(() => {
if (map != null) {
map.invalidateSize();
}
}, [map, height]);
const mapContainer = map.getContainer();
mapContainer.style.cssText = `height: ${height}; width: 100%; position: relative;`;
return null;
}
return (
<MapContainer
style={{ height: props.height || "80vh", width: "100%" }}
center={props.centroid}
zoom={8}
scrollWheelZoom={false}
>
<SetHeightOnChange height={props.height || "80vh"} />
<TileLayer
attribution="Google Maps Satellite"
url="https://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}"
/>
<Polyline
key={index}
positions={props.shape.vertices}
pathOptions={{
color: legend.find(item => item.value === props.shape.legend)?.color || "blue",
}}
/>
</MapContainer>
)
}