Skip to content

Instantly share code, notes, and snippets.

@eugenekgn
Created November 13, 2017 19:41
Show Gist options
  • Save eugenekgn/67c534e537568d304d9b63a6bcb1a7c8 to your computer and use it in GitHub Desktop.
Save eugenekgn/67c534e537568d304d9b63a6bcb1a7c8 to your computer and use it in GitHub Desktop.
google-map-field
import React from 'react'
import PropTypes from 'prop-types'
import { withScriptjs, withGoogleMap, GoogleMap, Marker } from 'react-google-maps'
import Field from 'redux-form/es/Field'
const _Maps = ( withScriptjs(withGoogleMap((props) =>
<GoogleMap
defaultZoom={ 8 }
defaultCenter={ { lat: -34.397, lng: 150.644 } }
loadingElement={ <div style={ { height: `100%` } }/> }
>
</GoogleMap>
)))
export function Maps({ ...props }){
//TODO: Streetview
const key = 'AIzaSyA7JfEizwtBAEM_QAiANL_lb5bNFgWq_Ek'
console.log(arguments)
return (
<Field
component={ _Maps }
googleMapURL={ `https://maps.googleapis.com/maps/api/js?key=${key}&v=3.exp&libraries=geometry,drawing,places` }
loadingElement={ <div style={ { height: `100%` } }/> }
containerElement={ <div style={ { height: `400px` } }/> }
mapElement={ <div style={ { height: `100%` } }/> }
{ ...props }
/>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment