Skip to content

Commit 193c07a

Browse files
author
Ajeet
committed
try react google map
1 parent 6c8d64e commit 193c07a

File tree

7 files changed

+205
-71
lines changed

7 files changed

+205
-71
lines changed

packages/rich-app/src/pages/home/homeLayout.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ import { showSuccessToast } from '../../utils/toastUtil'
1313
import { copyInputTextToClipboard } from '../../utils/commonUtils'
1414
import { ICar } from './iHome'
1515
import useDocumentTitle from '../../hooks/useDocumentTitle'
16+
import axios from 'axios'
1617

1718
export default function HomeContainer() {
19+
axios.get('https://quotesland-apis.herokuapp.com/v1/quotes/quote-of-the-day')
20+
1821
useDocumentTitle('Home')
1922
const { formatMessage } = useIntl()
2023
const dispatch: any = useDispatch()

packages/typescript-app/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"react-app-polyfill": "^3.0.0",
4747
"react-dev-utils": "^12.0.0",
4848
"react-dom": "^17.0.2",
49+
"react-google-maps": "^9.4.5",
4950
"react-refresh": "^0.11.0",
5051
"resolve": "^1.20.0",
5152
"resolve-url-loader": "^4.0.0",

packages/typescript-app/src/App.css

-38
This file was deleted.

packages/typescript-app/src/App.tsx

+9-19
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import { MyMapComponent } from './components/Map'
42

53
function App() {
64
return (
75
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.tsx</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
6+
<MyMapComponent
7+
googleMapURL="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places"
8+
loadingElement={<div style={{ height: `100%` }} />}
9+
containerElement={<div style={{ height: `400px` }} />}
10+
mapElement={<div style={{ height: `100%` }} />}
11+
/>
2212
</div>
23-
);
13+
)
2414
}
2515

26-
export default App;
16+
export default App
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { withScriptjs, withGoogleMap, GoogleMap, Marker } from 'react-google-maps'
2+
3+
export const MyMapComponent = withScriptjs(
4+
withGoogleMap((props: any) => (
5+
<GoogleMap zoom={18} defaultCenter={{ lat: -34.397, lng: 150.644 }}>
6+
<Marker
7+
position={{ lat: -34.397, lng: 150.644 }}
8+
icon={{
9+
url: 'https://cdn1.iconfinder.com/data/icons/Map-Markers-Icons-Demo-PNG/256/Map-Marker-Marker-Outside-Pink.png',
10+
innerWidth: 100,
11+
innerHeight: 100,
12+
}}
13+
/>
14+
</GoogleMap>
15+
))
16+
)

packages/typescript-app/src/index.tsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
5-
import reportWebVitals from './reportWebVitals';
1+
import React from 'react'
2+
import ReactDOM from 'react-dom'
3+
import './index.css'
4+
import App from './App'
5+
import reportWebVitals from './reportWebVitals'
66

77
ReactDOM.render(
88
<React.StrictMode>
99
<App />
1010
</React.StrictMode>,
1111
document.getElementById('root')
12-
);
12+
)
1313

1414
// If you want to start measuring performance in your app, pass a function
1515
// to log results (for example: reportWebVitals(console.log))
1616
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17-
reportWebVitals();
17+
reportWebVitals()

0 commit comments

Comments
 (0)