Skip to content

Commit

Permalink
feat(examples): adjust template
Browse files Browse the repository at this point in the history
  • Loading branch information
mrMetalWood committed Jan 22, 2024
1 parent 61db3f8 commit ccc3c16
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/_template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<div id="app"></div>
<script type="module">
import '@vis.gl/react-google-maps/examples.css';
import '@vis.gl/react-google-maps/examples.js';
import {renderToDom} from './src/app';

renderToDom(document.querySelector('#app'));
Expand Down
19 changes: 15 additions & 4 deletions examples/_template/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import React, {FunctionComponent} from 'react';
import React from 'react';
import {createRoot} from 'react-dom/client';

import {APIProvider, Map} from '@vis.gl/react-google-maps';
import ControlPanel from './control-panel';

const API_KEY = process.env.GOOGLE_MAPS_API_KEY as string;

const App = () => <APIProvider apiKey={API_KEY}></APIProvider>;
const API_KEY =
globalThis.GOOGLE_MAPS_API_KEY ?? (process.env.GOOGLE_MAPS_API_KEY as string);

const App = () => (
<APIProvider apiKey={API_KEY}>
<Map
zoom={3}
center={{lat: 22.54992, lng: 0}}
gestureHandling={'greedy'}
disableDefaultUI={true}
/>
<ControlPanel />
</APIProvider>
);
export default App;

export function renderToDom(container: HTMLElement) {
Expand Down
6 changes: 6 additions & 0 deletions examples/_template/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export default defineConfig(({mode}) => {
return {
define: {
'process.env.GOOGLE_MAPS_API_KEY': JSON.stringify(GOOGLE_MAPS_API_KEY)
},
resolve: {
alias: {
'@vis.gl/react-google-maps/examples.js':
'https://visgl.github.io/react-google-maps/scripts/examples.js'
}
}
};
});

0 comments on commit ccc3c16

Please sign in to comment.