Skip to content

Instantly share code, notes, and snippets.

@SpangleLabs
Last active May 13, 2020 18:18
Show Gist options
  • Save SpangleLabs/d89a2f947b9c3b3c4ddafaebfca1df6b to your computer and use it in GitHub Desktop.
Save SpangleLabs/d89a2f947b9c3b3c4ddafaebfca1df6b to your computer and use it in GitHub Desktop.
InfoWindow in Marker map test for @react-google-maps/api PR
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="MapTest.tsx"></script>
</head>
<body>
<div id="main">
</div>
</body>
</html>
import * as ReactDOM from "react-dom";
import * as React from "react";
import {GoogleMap, InfoWindow, LoadScript, Marker} from "@react-google-maps/api";
//import LoadScript from "../../../react-google-maps-api/packages/react-google-maps-api/src/LoadScript";
//import GoogleMap from "../../../react-google-maps-api/packages/react-google-maps-api/src/GoogleMap"
//import InfoWindow from "../../../react-google-maps-api/packages/react-google-maps-api/src/components/drawing/InfoWindow"
//import Marker from "../../../react-google-maps-api/packages/react-google-maps-api/src/components/drawing/Marker"
import config from "./config";
export const MapTest: React.FunctionComponent = () => {
const mapCentre = {lat: 55, lng: -3}
const mapStyle = {
height: "800px",
width: "800px"
}
const markerPosition = {lat: 57, lng: -3}
return <LoadScript googleMapsApiKey={config['google_maps_key']}>
<GoogleMap
zoom={6}
center={mapCentre}
id="map"
mapContainerStyle={mapStyle}
>
<Marker position={markerPosition}>
<InfoWindow>
<div>Hello</div>
</InfoWindow>
</Marker>
</GoogleMap>
</LoadScript>
}
document.addEventListener("DOMContentLoaded", function () {
ReactDOM.render(<MapTest/>, document.getElementById("main"));
});
@SpangleLabs
Copy link
Author

I've edited now, to pull those objects out higher into the component. I can easily pull those out the function if you want.
But it should demonstrate that the PR works at least

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment