How to enable or disable traffic in my map? #388
-
Hello guys, is there a way on how to enable or disable traffic layer on my map? I am not finding a way on how to do that. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Answered by
usefulthink
May 28, 2024
Replies: 1 comment 2 replies
-
One way would be to create a component for that: const TrafficLayer = () => {
const map = useMap();
useEffect(() => {
if(!map) return;
const trafficLayer = new google.maps.TrafficLayer({map, autoRefresh: false});
return () => { trafficLayer.setMap(null); };
}, [map]);
return <></>;
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
anxheloo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One way would be to create a component for that: