Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit 96c6a84

Browse files
committed
Fix google map is broken
1 parent 45fd95f commit 96c6a84

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

dist/bundle.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48458,9 +48458,10 @@ var Map = /** @class */ (function (_super) {
4845848458
// remove this key when you run it on your localhost.
4845948459
var script = document.createElement("script");
4846048460
script.type = "text/javascript";
48461-
script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyB5o5wtvz2sf_ckQm9rciFuJxc4pp2Sx-o";
48461+
script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyB5o5wtvz2sf_ckQm9rciFuJxc4pp2Sx-o&callback=initMap";
4846248462
script.async = true;
48463-
script.onloadend = this.onLoaded;
48463+
document.body.appendChild(script);
48464+
window.initMap = this.onLoaded;
4846448465
};
4846548466
Map.prototype.render = function () {
4846648467
return (React.createElement("div", { id: "map" }));

dist/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Map.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import * as React from "react";
22

3+
declare global {
4+
interface Window {
5+
initMap: Function;
6+
}
7+
}
8+
39
export interface MapProps {
410
getWeather: (lat: number, lng: number) => void;
511
mapReady: () => void;
@@ -22,9 +28,10 @@ export default class Map extends React.Component<MapProps, MapState> {
2228
// remove this key when you run it on your localhost.
2329
const script = document.createElement("script");
2430
script.type = "text/javascript";
25-
script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyB5o5wtvz2sf_ckQm9rciFuJxc4pp2Sx-o";
31+
script.src = "https://maps.googleapis.com/maps/api/js?key=AIzaSyB5o5wtvz2sf_ckQm9rciFuJxc4pp2Sx-o&callback=initMap";
2632
script.async = true;
27-
script.onloadend = this.onLoaded;
33+
document.body.appendChild(script);
34+
window.initMap = this.onLoaded;
2835
}
2936

3037
public render() {

0 commit comments

Comments
 (0)