|
@@ -0,0 +1,33 @@
|
|
|
+import React, { useRef, useEffect } from "react";
|
|
|
+/* global google */
|
|
|
+
|
|
|
+// TODO might want to look into forcing this to avoid updates
|
|
|
+export default ({
|
|
|
+ onMapClick
|
|
|
+}) => {
|
|
|
+ const mapDivRef = useRef(null);
|
|
|
+ useEffect(() => {
|
|
|
+ const googleMap = new google.maps.Map(mapDivRef.current, {
|
|
|
+ center: { lat: 25, lng: -25 },
|
|
|
+ zoom: 0,
|
|
|
+ disableDefaultUI: true,
|
|
|
+ fullscreenControl: true,
|
|
|
+ });
|
|
|
+ console.log("Created Map");
|
|
|
+ if (onMapClick) {
|
|
|
+ console.log("Adding click listener");
|
|
|
+ googleMap.addListener("click", ({latLng}) => onMapClick(googleMap, latLng));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div style={{
|
|
|
+ height: "100%",
|
|
|
+ display: "flex",
|
|
|
+ flexDirection: "column",
|
|
|
+ justifyContent: "center",
|
|
|
+ }}
|
|
|
+ ref={mapDivRef}
|
|
|
+ />
|
|
|
+ );
|
|
|
+};
|