|
@@ -1,21 +1,6 @@
|
|
|
-import React, { useRef, useEffect } from "react";
|
|
|
+import React, { useRef } from "react";
|
|
|
import useMap from "../../../hooks/useMap";
|
|
|
-/* global google */
|
|
|
-
|
|
|
-const useClickMarker = (map, onMove) => {
|
|
|
- const marker = useRef(null);
|
|
|
- useEffect(() => {
|
|
|
- const listener = map.current.addListener("click", ({ latLng }) => {
|
|
|
- if (marker.current) {
|
|
|
- marker.current.setMap(null);
|
|
|
- }
|
|
|
- marker.current = new google.maps.Marker({ map: map.current, position: latLng });
|
|
|
- onMove({ lat: latLng.lat(), lng: latLng.lng() });
|
|
|
- });
|
|
|
-
|
|
|
- return () => { google.maps.event.removeListener(listener); }
|
|
|
- }, [map, onMove]);
|
|
|
-}
|
|
|
+import useClickMarker from "./useClickMarker";
|
|
|
|
|
|
export default ({ onMarkerMoved }) => {
|
|
|
const mapDivRef = useRef(null);
|