(props: PropsWithChildren<IProps>)
| 38 | } |
| 39 | |
| 40 | function 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 | |
| 84 | export type MarkerColor = |
| 85 | | "red" |
nothing calls this directly
no test coverage detected