Drawing Manager #164
Closed
apeTrackunit
started this conversation in
Ideas
Replies: 2 comments 5 replies
-
Are you thinking about interactive drawings or just adding polygons and such to the map? |
Beta Was this translation helpful? Give feedback.
1 reply
-
If you want to use the DrawingManager, it's probably something like this: import { useMap, useMapsLibrary } from "@vis.gl/react-google-maps";
const DrawingManager = ({ drawingManagerOptions }) => {
const map = useMap();
const drawingLib = useMapsLibrary("drawing");
const [manager, setManager] = useState(null);
useEffect(() => {
if (!map || !drawingLib) return;
const drawingManager = new drawingLib.DrawingManager(drawingManagerOptions);
setManager(drawingManager);
drawingManager.setMap(map);
return () => {
// remove from map and reset state
drawingManager.setMap(null);
setManager(null);
};
}, [map, drawingLib]);
useEffect(() => {
if (!drawingManager) return;
// setup event-handlers etc
}, [drawingManager]);
}; |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm currently looking for a way to allow users to draw custom polygons on the map using the library. Is there an existing Drawing Manager component, or are there alternative solutions that I can implement for this purpose?
Any insights or guidance on this matter would be greatly appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions