Skip to content

Commit 046d60a

Browse files
committed
feat(Map): add hideAttribution prop to control attribution visibility
Add hideAttribution prop to all Map components to control the visibility of Leaflet attribution control in the bottom-right corner. Changes: - Add hideAttribution?: boolean prop to MapViewProps (default: true) - Update MapContent to apply conditional 'show-attribution' class - Update Map.module.css with conditional attribution display rules - Pass prop through Map, CompactMap, and FullscreenMap components - Add documentation to Maps.stories.tsx Advanced Features section Usage: - hideAttribution={false} - Show attribution (licensing compliant) - hideAttribution={true} - Hide attribution (default, backward compatible) Future: Default will change to false (show) for licensing compliance.
1 parent b314fb1 commit 046d60a

File tree

6 files changed

+76
-6
lines changed

6 files changed

+76
-6
lines changed

packages/ui/src/components/Map/CompactMap.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const CompactMap: React.FC<CompactMapProps> = ({
7575
isInspectorOpen,
7676
scrollWheelZoom,
7777
showPopup,
78+
hideAttribution,
7879
loading = false,
7980
error = false,
8081
height = DEFAULT_HEIGHT,
@@ -111,6 +112,7 @@ export const CompactMap: React.FC<CompactMapProps> = ({
111112
isInspectorOpen={isInspectorOpen}
112113
scrollWheelZoom={scrollWheelZoom}
113114
showPopup={showPopup}
115+
hideAttribution={hideAttribution}
114116
loading={loading}
115117
error={error}
116118
tileProvider={tileProvider}

packages/ui/src/components/Map/Map.module.css

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,16 @@
177177
display: none !important;
178178
}
179179

180-
/* Hide Leaflet attribution */
181-
:global(.leaflet-control-attribution) {
182-
display: none !important;
180+
/* Hide Leaflet attribution by default */
181+
.mapContainer :global(.leaflet-control-attribution) {
182+
display: none;
183+
}
184+
185+
/* Show attribution when hideAttribution is false */
186+
.mapContainer:global(.show-attribution) :global(.leaflet-control-attribution) {
187+
display: block !important;
188+
}
189+
190+
:global(.show-attribution) .mapContainer :global(.leaflet-control-attribution) {
191+
display: block !important;
183192
}

packages/ui/src/components/Map/Map.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const Map: React.FC<MapProps> = ({
7171
isInspectorOpen,
7272
scrollWheelZoom,
7373
showPopup,
74+
hideAttribution,
7475
autoExpandOnCarouselClick = false,
7576
loading = false,
7677
error = false,
@@ -146,6 +147,7 @@ export const Map: React.FC<MapProps> = ({
146147
isInspectorOpen,
147148
scrollWheelZoom,
148149
showPopup,
150+
hideAttribution,
149151
loading,
150152
error,
151153
tileProvider,

packages/ui/src/components/Map/MapContent.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TILE_PROVIDER_PRESETS, type TileProviderConfig } from './tileProviders'
88
import { Features } from '../Feature/Features';
99
import { ThemeContext } from '../../providers/ThemeProvider';
1010
import type { ThemeContextValue } from '../../providers/ThemeProvider';
11+
import { cn } from '../../utils/cn';
1112
import styles from './Map.module.css';
1213

1314
/**
@@ -418,12 +419,15 @@ export const MapContent: React.FC<MapViewProps> = ({
418419
isInspectorOpen,
419420
scrollWheelZoom = false,
420421
showPopup = true,
422+
hideAttribution = true,
421423
tileProvider,
422424
tileApiKey,
423425
}) => {
424-
const containerClassName = className
425-
? `${styles.mapContainer} ${className}`
426-
: styles.mapContainer;
426+
const containerClassName = cn(
427+
styles.mapContainer,
428+
!hideAttribution && 'show-attribution',
429+
className
430+
);
427431

428432
// Resolve tile provider configuration
429433
const tileConfig = useMemo(

packages/ui/src/components/Map/MapView.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ export interface MapViewProps {
135135
*/
136136
showPopup?: boolean;
137137

138+
/**
139+
* Hide Leaflet attribution control.
140+
* When true, hides the attribution text in bottom-right corner.
141+
* Note: Attribution is required by most tile providers' terms of service.
142+
* @default true (for backward compatibility, will change to false in future)
143+
*/
144+
hideAttribution?: boolean;
145+
138146
/**
139147
* Tile provider configuration.
140148
*

packages/ui/src/components/Map/Maps.stories.tsx

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,51 @@ const handleMapToggle = (fullscreen: boolean) => {
10171017
<code>{`<Map
10181018
locations={locations}
10191019
autoExpandOnCarouselClick={true}
1020+
/>`}</code>
1021+
</pre>
1022+
</div>
1023+
1024+
{/* Attribution Control */}
1025+
<div
1026+
style={{
1027+
padding: '16px',
1028+
background: 'var(--ai-color-bg-secondary)',
1029+
borderRadius: '12px',
1030+
border: '1px solid var(--ai-color-border-default)',
1031+
}}
1032+
>
1033+
<h3 style={{ fontSize: '16px', marginBottom: '8px', fontWeight: 600 }}>
1034+
Attribution Control
1035+
</h3>
1036+
<p style={{ margin: '0 0 12px', fontSize: '14px', color: 'var(--ai-color-text-secondary)' }}>
1037+
Control the visibility of Leaflet attribution using the <code>hideAttribution</code> prop.
1038+
By default, attribution is hidden. Set to <code>false</code> to display tile provider
1039+
credits in the bottom-right corner.
1040+
</p>
1041+
<div style={{ fontSize: '13px', color: 'var(--ai-color-text-secondary)', marginBottom: '12px' }}>
1042+
<strong>Note:</strong> Attribution is required by most tile providers' terms of service.
1043+
</div>
1044+
<pre
1045+
style={{
1046+
margin: 0,
1047+
padding: '12px',
1048+
background: 'var(--ai-color-bg-tertiary)',
1049+
borderRadius: '6px',
1050+
fontSize: '12px',
1051+
lineHeight: '1.5',
1052+
fontFamily: 'Monaco, Menlo, monospace',
1053+
}}
1054+
>
1055+
<code>{`// Show attribution (licensing compliant)
1056+
<Map
1057+
locations={locations}
1058+
hideAttribution={false}
1059+
/>
1060+
1061+
// Hide attribution (default)
1062+
<Map
1063+
locations={locations}
1064+
hideAttribution={true}
10201065
/>`}</code>
10211066
</pre>
10221067
</div>

0 commit comments

Comments
 (0)