-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also, remove interactivity from BreweryPage map
- Loading branch information
1 parent
a6f4804
commit 6962dda
Showing
5 changed files
with
111 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,78 @@ | ||
import React from 'react'; | ||
import React, {Component} from 'react'; | ||
import GoogleMap from 'google-map-react'; | ||
import autoBind from 'react-autobind'; | ||
import BreweryMarker from '../BreweryMarker/BreweryMarker'; | ||
|
||
const BreweryMap = ({ | ||
googleMapsApiKey, | ||
mapCenter, | ||
mapZoom, | ||
breweries, | ||
activeCity | ||
}) => { | ||
|
||
return ( | ||
<GoogleMap | ||
bootstrapURLKeys={{ key: googleMapsApiKey, language: 'en' }} | ||
center={ mapCenter } | ||
zoom={ mapZoom } | ||
defaultZoom={ 12 } | ||
> | ||
{ | ||
Object.keys(breweries).map((breweryKey) => | ||
<BreweryMarker | ||
key={ breweryKey } | ||
lat={ breweries[breweryKey].location.lat } | ||
lng={ breweries[breweryKey].location.lng } | ||
pageUrl={ `/${activeCity}/${breweryKey}` } | ||
breweryKey={ breweryKey } | ||
brewery={ breweries[breweryKey] } | ||
/> | ||
) | ||
} | ||
</GoogleMap> | ||
); | ||
class BreweryMap extends Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
autoBind(this); | ||
this.state = { | ||
pulsing: null | ||
} | ||
} | ||
|
||
componentWillMount() { | ||
var interval = setInterval(this.randomBrewery, 7000); | ||
this.setState({ | ||
interval: interval | ||
}) | ||
} | ||
|
||
componentWillUnmount() { | ||
clearInterval(this.state.interval); | ||
} | ||
|
||
randomBrewery() { | ||
this.setState({ | ||
pulsing: Math.floor(Math.random() * Object.keys(this.props.breweries).length) | ||
}); | ||
} | ||
|
||
render() { | ||
const { | ||
googleMapsApiKey, | ||
mapCenter, | ||
mapZoom, | ||
breweries, | ||
activeCity, | ||
interactive = true, | ||
} = this.props; | ||
|
||
return ( | ||
<GoogleMap | ||
bootstrapURLKeys={{ key: googleMapsApiKey, language: 'en' }} | ||
center={ mapCenter } | ||
zoom={ mapZoom } | ||
options={!interactive && | ||
{ | ||
disableDefaultUI:true, | ||
draggable: false, | ||
zoomControl: false, | ||
scrollwheel: false, | ||
disableDoubleClickZoom: true | ||
} | ||
} | ||
defaultZoom={ 12 } | ||
> | ||
{ | ||
Object.keys(breweries).map((breweryKey, idx) => | ||
<BreweryMarker | ||
key={ breweryKey } | ||
lat={ breweries[breweryKey].location.lat } | ||
lng={ breweries[breweryKey].location.lng } | ||
pageUrl={ `/${activeCity}/${breweryKey}` } | ||
breweryKey={ breweryKey } | ||
brewery={ breweries[breweryKey] } | ||
pulsing={ interactive && idx === this.state.pulsing } | ||
/> | ||
) | ||
} | ||
</GoogleMap> | ||
); | ||
} | ||
} | ||
|
||
|
||
export default BreweryMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters