MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / Map

Function Map

ui/src/components/Map.tsx:40–82  ·  view source on GitHub ↗
(props: PropsWithChildren<IProps>)

Source from the content-addressed store, hash-verified

38}
39
40function Map(props: PropsWithChildren<IProps>) {
41 const [tileserver, setTileserver] = useState<string>("");
42 const [attribution, setAttribution] = useState<string>("");
43
44 useEffect(() => {
45 const updateMapProperties = () => {
46 InternalStore.settings(v => {
47 setTileserver(v.getTileserverUrl());
48 setAttribution(v.getMapAttribution());
49 });
50 };
51
52 InternalStore.on("change", updateMapProperties);
53 updateMapProperties();
54
55 return () => {
56 InternalStore.removeListener("change", updateMapProperties);
57 };
58 }, [props]);
59
60 const style = {
61 height: props.height,
62 };
63
64 if (attribution === "" || tileserver === "") {
65 return null;
66 }
67
68 return (
69 <MapContainer
70 bounds={props.bounds}
71 boundsOptions={props.boundsOptions}
72 center={props.center}
73 zoom={13}
74 scrollWheelZoom={false}
75 style={style}
76 >
77 <TileLayer attribution={attribution} url={tileserver} />
78 {props.children}
79 <MapControl bounds={props.bounds} boundsOptions={props.boundsOptions} center={props.center} />
80 </MapContainer>
81 );
82}
83
84export type MarkerColor =
85 | "red"

Callers

nothing calls this directly

Calls 1

updateMapPropertiesFunction · 0.85

Tested by

no test coverage detected