You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
650 B
18 lines
650 B
import { useEffect, useRef } from 'react'; |
|
export function useAttribution(map, attribution) { |
|
const attributionRef = useRef(attribution); |
|
useEffect(function updateAttribution() { |
|
if (attribution !== attributionRef.current && map.attributionControl != null) { |
|
if (attributionRef.current != null) { |
|
map.attributionControl.removeAttribution(attributionRef.current); |
|
} |
|
if (attribution != null) { |
|
map.attributionControl.addAttribution(attribution); |
|
} |
|
} |
|
attributionRef.current = attribution; |
|
}, [ |
|
map, |
|
attribution |
|
]); |
|
}
|
|
|