Skip to content

Commit 2932be8

Browse files
Merge branch 'master' into single-user
2 parents 36610e2 + 23de422 commit 2932be8

19 files changed

+1287
-401
lines changed

.eslintrc.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"root": true,
3+
"parser": "babel-eslint",
4+
"extends": "fullstack",
5+
"rules": {
6+
"semi": 0,
7+
"new-cap": [1, { "capIsNewExceptions": ["Router"] }]
8+
}
9+
}

.firebaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"projects": {
33
"mapit": "map-it-fsa"
44
}
5-
}
5+
}

App.jsx

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
import React, { Component } from "react";
22
import { Route, Switch } from "react-router-dom";
3-
import GoogleMap from "./GoogleMap";
3+
import Map from './components/maps/Map';
44
import Login from "./Login";
55
import Sidebar from "./Sidebar";
66
import SingleUser from "./SingleUser";
7-
import { GoogleApiWrapper } from "google-maps-react";
87
import firebase, { auth } from "~/fire";
98
import NavBar from "./Navbar";
109
import NewMap from "./NewMap";
1110
import CircularLoad from "./CircularProgress";
12-
import FollowingUsers from "./FollowingUsers"
11+
import FollowingUsers from "./FollowingUsers";
1312
import FollowersUsers from "./FollowersUsers";
14-
import CreatedMap from './components/CreatedMap'
15-
import AllMaps from './components/AllMaps'
13+
import CreatedMap from "./components/CreatedMap";
14+
import AllMaps from "./components/AllMaps";
15+
import MapView from "./components/MapView"
1616

1717
const db = firebase.firestore();
18+
const maps = db.collection('maps')
1819

19-
class App extends Component {
20+
export default class App extends Component {
2021
constructor() {
2122
super();
2223
this.state = {
@@ -114,7 +115,8 @@ class App extends Component {
114115

115116
render() {
116117
const { user, documentId, numFollowers, numFollowing } = this.state;
117-
if (this.state.loading === true) return <CircularLoad size={200} color={`secondary`} />;
118+
if (this.state.loading === true)
119+
return <CircularLoad size={200} color={`secondary`} />;
118120
if (!user) return <Login user={user} />;
119121
return (
120122
<div>
@@ -132,19 +134,15 @@ class App extends Component {
132134
<div className="col-2">
133135
<Switch>
134136
<Route
135-
exact
136-
path="/"
137+
exact path="/"
137138
render={() => (
138-
<GoogleMap
139-
google={{
140-
...this.props.google,
141-
loc: { lat: 20, lng: -70 },
142-
user: user
143-
}}
139+
<Map
140+
google={this.props.google}
141+
defaultCenter={{lat: 20, lng: -70}}
142+
defaultZoom={10}
144143
/>
145144
)}
146145
/>
147-
)} />
148146
<Route
149147
exact
150148
path="/following/:userId"
@@ -172,31 +170,18 @@ class App extends Component {
172170
path="/newmap/:id"
173171
render={() => <NewMap google={this.props.google} />}
174172
/>
175-
<Route
176-
exact path="/allmaps/:uid"
173+
<Route
174+
exact
175+
path="/allmaps/:uid"
177176
render={() => <AllMaps signedInUser={user} />}
178177
/>
179178
<Route
180179
exact
181180
path="/map/:id"
182-
render={() => (
183-
<CreatedMap
184-
google={this.props.google}
185-
followerUserId={this.state.user.uid}
186-
/>
187-
)}
188-
/>
189-
<Route
190-
path="/"
191-
render={() => (
192-
<GoogleMap
193-
google={{
194-
...this.props.google,
195-
loc: { lat: 20, lng: -70 },
196-
user: user
197-
}}
198-
/>
199-
)}
181+
component={
182+
({match: {params: {id}}}) =>
183+
<MapView of={maps.doc(id)} />
184+
}
200185
/>
201186
)} />
202187
</Switch>
@@ -206,7 +191,3 @@ class App extends Component {
206191
);
207192
}
208193
}
209-
210-
export default GoogleApiWrapper({
211-
apiKey: "AIzaSyBNO9SHxnyzMG6J1FCDYcle7DjXMjg6jBU"
212-
})(App);

GoogleMap.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class GoogleMap extends Component {
3939
if (e.target.name === "title") {
4040
title = e.target.value;
4141
} else if (e.target.name === "tags") {
42-
tags = e.target.value.split(" ").map(tag => tag.toLowerCase().replace(/^#/, ""));
42+
tags = e.target.value.split(" ").filter(x => x).map(tag => tag.toLowerCase().replace(/^#/, ""));
43+
console.log('tags -->', tags)
4344
}
4445
};
4546

@@ -57,11 +58,6 @@ class GoogleMap extends Component {
5758
}
5859

5960
createNewMap() {
60-
// let center = {
61-
// lat: this.map.getCenter().lat(),
62-
// lng: this.map.getCenter().lng()
63-
// };
64-
6561
this.setState({center:{
6662
lat: this.map.getCenter().lat(),
6763
lng: this.map.getCenter().lng()
@@ -73,7 +69,8 @@ class GoogleMap extends Component {
7369
center: this.state.center,
7470
uid: this.props.google.user.uid,
7571
places: {},
76-
title: title
72+
title: title,
73+
tags: {...tags.map(tag => ( { [tag]: true } ))}
7774
})
7875
.then(map => {
7976
let mapId = map.id;
@@ -145,6 +142,9 @@ class GoogleMap extends Component {
145142
}
146143
);
147144
this.map = new maps.Map(node, mapConfig); // creates a new Google map on the specified node (ref='map') with the specified configuration set above.
145+
146+
this.map.addListener('click', this.mapWasClicked)
147+
148148
const service = new google.maps.places.PlacesService(this.map);
149149
const defaultBounds = new google.maps.LatLngBounds(
150150
new google.maps.LatLng(-33.8902, 151.1759),
@@ -159,6 +159,10 @@ class GoogleMap extends Component {
159159
}
160160
}
161161

162+
mapWasClicked = (event) => {
163+
console.log('EVENT!!!! 🏳️‍🌈 -->', event.latLng);
164+
}
165+
162166
render() {
163167
const { classes } = this.props;
164168
const { openNewForm, centerMap } = this.state;

SearchBar.jsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,17 @@ class SearchBar extends Component {
2828
}
2929

3030
render() {
31-
32-
3331
return (
34-
<form onSubmit={this.handleSubmit}>
35-
<input className='google-map-input' name="displayName" type='text' placeholder='Search Users' />
36-
</form>
37-
38-
32+
<form onSubmit={this.handleSubmit}>
33+
<input
34+
className="google-map-input"
35+
name="displayName"
36+
type="text"
37+
placeholder="Search Users"
38+
/>
39+
</form>
3940
);
4041
}
4142
}
4243

4344
export default withRouter(SearchBar);
44-
45-
// <input type="text" name="displayName" />

babel.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ const babel = module.exports = env => ({
44
loader: 'babel-loader',
55
options: {
66
presets: [
7-
['env', {modules: false}],
7+
['env', {
8+
modules: false,
9+
targets: 'last 2 versions',
10+
}],
811
'stage-2',
912
'react',
1013
],
1114
plugins: isHot(env) && ['react-hot-loader/babel']
1215
}
13-
})
16+
})

0 commit comments

Comments
 (0)