Closed siner308 closed 3 years ago
useEffect(() => {
if(!window.kakao || !window.map) {
return;
}
const clickEvent = (e: any): void => {
setCreatePlaceLatLng({
latitude: e.latLng.getLat(),
longitude: e.latLng.getLng(),
});
};
if (createPlaceButtonClicked) {
events.push(clickEvent);
window.map.setCursor('crosshair');
window.kakao.maps.event.addListener(window.map, 'click', clickEvent);
} else {
window.map?.setCursor('grab');
window.kakao?.maps.event.removeListener(window.map, 'click', events.pop());
}
}, [createPlaceButtonClicked]);
https://github.com/siner308/ttbkk-web/blob/726f4fb308e82ae6ed8077ad088c16d5ed989150/src/components/Toolbar/CreatePlaceButton.tsx#L15