diff --git a/examples/basic/public/antennas/carrier-att.svg b/examples/basic/public/antennas/carrier-att.svg new file mode 100644 index 0000000..cab1109 --- /dev/null +++ b/examples/basic/public/antennas/carrier-att.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/basic/public/antennas/carrier-others.svg b/examples/basic/public/antennas/carrier-others.svg new file mode 100644 index 0000000..3c093f7 --- /dev/null +++ b/examples/basic/public/antennas/carrier-others.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/basic/public/antennas/carrier-tmobile.svg b/examples/basic/public/antennas/carrier-tmobile.svg new file mode 100644 index 0000000..6f4fe16 --- /dev/null +++ b/examples/basic/public/antennas/carrier-tmobile.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/basic/public/antennas/carrier-verizon.svg b/examples/basic/public/antennas/carrier-verizon.svg new file mode 100644 index 0000000..149d169 --- /dev/null +++ b/examples/basic/public/antennas/carrier-verizon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/examples/basic/src/components/BelowMapCard.tsx b/examples/basic/src/components/BelowMapCard.tsx new file mode 100644 index 0000000..5190180 --- /dev/null +++ b/examples/basic/src/components/BelowMapCard.tsx @@ -0,0 +1,25 @@ +import { createContext, useContext, type ReactNode } from 'react'; +import { createPortal } from 'react-dom'; + +/** The element under the map stage where SamplePageLayout puts a page's below-map card. */ +export const BelowMapSlot = createContext(null); + +/** + * A sample's options as a card under the map instead of a ControlPanel over it, for pages + * whose controls would hide too much of the map. + * + * The page renders inside the map stage, so the card is portalled out to the layout's slot. + * The slot is only known after mount, which also keeps the server-rendered page (where + * portals do not render) and the first client paint the same. + */ +export function BelowMapCard({ title, children }: { title: string; children: ReactNode }) { + const slot = useContext(BelowMapSlot); + if (!slot) return null; + return createPortal( +
+

{title}

+ {children} +
, + slot, + ); +} diff --git a/examples/basic/src/components/SamplePageLayout.tsx b/examples/basic/src/components/SamplePageLayout.tsx index c510bb1..311f61a 100644 --- a/examples/basic/src/components/SamplePageLayout.tsx +++ b/examples/basic/src/components/SamplePageLayout.tsx @@ -3,6 +3,7 @@ import type { SupportedLanguage } from '../samples/sampleRegistry'; import { SamplePageSeo } from '../samples/SamplePageSeo'; import { SampleDocumentation } from './SampleDocumentation'; import { SampleIntroOverlay } from './SampleIntroOverlay'; +import { BelowMapSlot } from './BelowMapCard'; import { translate } from '../samples/i18n'; export function SamplePageLayout({ @@ -17,6 +18,7 @@ export function SamplePageLayout({ children?: ReactNode; }) { const { stageRef, fullscreen, toggleFullscreen } = useMapFullscreen(); + const [belowMap, setBelowMap] = useState(null); const labels = { enter: translate(language, { en: 'Full screen', ja: '全画面表示', 'es-419': 'Pantalla completa', de: 'Vollbild', th: 'เต็มหน้าจอ', hi: 'फ़ुल स्क्रीन' }), exit: translate(language, { en: 'Exit full screen', ja: '全画面表示を終了', 'es-419': 'Salir de pantalla completa', de: 'Vollbild beenden', th: 'ออกจากโหมดเต็มหน้าจอ', hi: 'फ़ुल स्क्रीन से बाहर निकलें' }), @@ -33,47 +35,50 @@ export function SamplePageLayout({ } return ( -
- -
-
- {/* Camera Sync has its own full screen, for both of its maps. */} - {page !== 'camera-sync' && } - {children ?? ( - - )} - + +
+ +
+
+ {/* Camera Sync has its own full screen, for both of its maps. */} + {page !== 'camera-sync' && } + {children ?? ( + + )} + +
+
+
- -
+
); } diff --git a/examples/basic/src/index.css b/examples/basic/src/index.css index 98440c6..a6e9c40 100644 --- a/examples/basic/src/index.css +++ b/examples/basic/src/index.css @@ -561,6 +561,21 @@ body, outline-offset: 2px; } +.below-map-card { + margin: 0 min(15px, 10vmin) min(15px, 10vmin); + padding: 16px; + border: 1px solid #d9dde7; + border-radius: 8px; + background: #ffffff; + color: #1f2937; + box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08); +} + +.below-map-card-title { + margin: 0 0 8px; + font-size: 16px; +} + .sample-documentation { margin: 0 min(15px, 10vmin) min(15px, 10vmin); padding: clamp(16px, 3vw, 28px); diff --git a/examples/basic/src/pages/circle/antennas/AntennaHorizonsPage.tsx b/examples/basic/src/pages/circle/antennas/AntennaHorizonsPage.tsx index 4101784..b63789f 100644 --- a/examples/basic/src/pages/circle/antennas/AntennaHorizonsPage.tsx +++ b/examples/basic/src/pages/circle/antennas/AntennaHorizonsPage.tsx @@ -2,7 +2,7 @@ import { useEffect, useMemo, useState } from 'react'; import { createCircleState, createGeoPoint, type CircleEvent, type CircleState } from '@mapconductor/js-sdk-core'; import { Circles, InfoBubble } from '@mapconductor/js-sdk-react'; import { MapViewContainer } from '../../../MapViewContainer'; -import { ControlPanel } from '../../../components/ControlPanel'; +import { BelowMapCard } from '../../../components/BelowMapCard'; import { LoadingOverlay, useLoadingOverlay } from '../../../components/LoadingOverlay'; import { decodeAntennas, type Antenna } from './antennaData'; @@ -10,6 +10,9 @@ const CARRIERS = ['AT&T', 'T-Mobile / Sprint', 'Verizon', 'Others']; const COLORS = ['37,99,235', '219,39,119', '217,119,6', '100,116,139']; const STROKE_COLORS = COLORS.map(color => `rgba(${color},0.35)`); const FILL_COLORS = COLORS.map(color => `rgba(${color},0.65)`); +// Drawn for this sample in the carrier's circle colour (not the carriers' logos); the +// Android and iOS samples ship the same drawing. +const CARRIER_ICONS = ['att', 'tmobile', 'verizon', 'others'].map(name => `/antennas/carrier-${name}.svg`); // Keep the population out of React's development performance-entry payload. class CircleSelection implements Iterable { @@ -67,11 +70,6 @@ export function AntennaHorizonsPage() { return () => { cancelled = true; }; }, [data]); const preparing = data != null && allStates.length !== data.length; - const counts = useMemo(() => { - const result = [0, 0, 0, 0]; - for (const row of data ?? []) result[row.carrier]++; - return result; - }, [data]); const states = useMemo(() => { if (carriers.length === CARRIERS.length) return allStates; if (!data || carriers.length === 0 || preparing) return []; @@ -79,16 +77,33 @@ export function AntennaHorizonsPage() { }, [allStates, data, carriers]); const selection = useMemo(() => new CircleSelection(states), [states]); useEffect(() => { setTap(null); }, [states]); - return setTap(null)}> - - - {tap &&
{CARRIERS[tap.carrier]}
Cell position · Display radius: 500 m
} - + return <> + setTap(null)}> + + + {tap &&
{CARRIERS[tap.carrier]}
Cell position · Display radius: 500 m
} +
+
{error || (!data ? 'Loading OpenCellID data…' : `${states.length.toLocaleString()} / ${data.length.toLocaleString()} circles`)}
- {CARRIERS.map((name, index) => )} +
+ {CARRIERS.map((name, index) => { + const on = carriers.includes(index); + return ; + })} +

Cell positions shown as 500 m radius circles; not signal coverage. Showing all cells for the selected carriers. MCC 310–314; not a complete tower inventory.

Cell tower data from OpenCellID · CC BY-SA 4.0
-
-
; + + ; }