Skip to content

Commit

Permalink
New Map Component working with Basic instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaldanha committed May 25, 2020
1 parent 7754b78 commit 5071a9d
Show file tree
Hide file tree
Showing 6 changed files with 254 additions and 20 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"dotenv": "^8.2.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-google-maps": "^9.4.5",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1"
"react-scripts": "3.4.1",
"styled-components": "^5.1.0"
},
"scripts": {
"start": "react-scripts start",
Expand Down
24 changes: 24 additions & 0 deletions src/components/Map/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import { MapContainer } from "./styled";
import { GoogleMap, withScriptjs, withGoogleMap } from "react-google-maps";

const GMap = () => (
<GoogleMap
defaultZoom={16}
defaultCenter={{ lat: -23.604710, lng: -46.634330}}
/>
)
const WrappedMap = withScriptjs(withGoogleMap(GMap));

const Map = () => (
<MapContainer>
<WrappedMap
googleMapURL={`https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=geometry,drawing,places&key=${process.env.REACT_APP_GOOGLE_KEY}`}
loadingElement={<div style={{height:`100%`}}/>}
containerElement={<div style={{height:`100%`}}/>}
mapElement={<div style={{height:`100%`}}/>}
/>
</MapContainer>
)

export default Map;
6 changes: 6 additions & 0 deletions src/components/Map/styled.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import styled from "styled-components";

export const MapContainer = styled.div`
width: 100vw;
height: 100vw;
`;
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
,
document.getElementById('root')
);

Expand Down
5 changes: 2 additions & 3 deletions src/pages/home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from "react";
import Map from "../../components/Map";

const Home = () => (
<div>
hello world bike de boa!
</div>
<Map />
)

export default Home;
Loading

0 comments on commit 5071a9d

Please sign in to comment.