Skip to content

Commit

Permalink
Create a simple google map component
Browse files Browse the repository at this point in the history
  • Loading branch information
jumpalottahigh committed Aug 27, 2018
1 parent 321cad3 commit b04f5c3
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 14 deletions.
27 changes: 13 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
env: {
browser: true,
es6: true,
},
"plugins": [
"react",
],
"globals": {
"graphql": false,
plugins: ['react'],
globals: {
graphql: false,
},
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true,
jsx: true,
},
}
},
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
"gatsby-source-filesystem": "next",
"gatsby-transformer-remark": "next",
"gatsby-transformer-sharp": "next",
"google-map-react": "^1.0.6",
"prismjs": "^1.15.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-helmet": "^5.2.0",
"styled-components": "^3.3.3"
},
"devDependencies": {
"babel-eslint": "^8.2.6",
"eslint": "^4.19.1",
"eslint-plugin-react": "^7.7.0",
"prettier": "^1.12.0"
Expand Down
35 changes: 35 additions & 0 deletions src/components/Map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import GoogleMapReact from 'google-map-react'

const AnyReactComponent = ({ text }) => <div>{text}</div>

class SimpleMap extends React.Component {
static defaultProps = {
center: {
lat: 59.95,
lng: 30.33,
},
zoom: 11,
}

render() {
return (
// Important! Always set the container height explicitly
<div style={{ height: '100vh', width: '100%' }}>
<GoogleMapReact
bootstrapURLKeys={{ key: '' }}
defaultCenter={this.props.center}
defaultZoom={this.props.zoom}
>
<AnyReactComponent
lat={59.955413}
lng={30.337844}
text={'Kreyser Avrora'}
/>
</GoogleMapReact>
</div>
)
}
}

export default SimpleMap
2 changes: 2 additions & 0 deletions src/pages/fpv-spots.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react'
import Map from '../components/Map'

const FPVSpotsPage = () => (
<div>
<h1>FPV Spots Page</h1>
<Map />
</div>
)

Expand Down

0 comments on commit b04f5c3

Please sign in to comment.