Skip to content

Commit a936040

Browse files
authored
Merge pull request #16 from CodeForPhilly/leaflet-dev
Leaflet dev
2 parents af4645b + 5d56ba4 commit a936040

6 files changed

Lines changed: 57 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to release number versioning.
1111

1212
- Set up React and Django boilerplate [#1](https://github.com/CodeForPhilly/third-places/pull/1)
1313
- Added Docker containers with docker-compose [#10](https://github.com/CodeForPhilly/third-places/pull/10)
14+
- Set up Leaflet React component and boiletplate homepage[#7](https://github.com/CodeForPhilly/third-places/issues/7)
1415
- Added initial Django models & migration [#21](https://github.com/CodeForPhilly/third-places/pull/21)
1516

1617
### Changed

src/app/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
"preview": "vite preview"
1010
},
1111
"dependencies": {
12+
"leaflet": "^1.9.3",
1213
"react": "^18.2.0",
13-
"react-dom": "^18.2.0"
14+
"react-dom": "^18.2.0",
15+
"react-leaflet": "^4.2.1"
1416
},
1517
"devDependencies": {
18+
"@types/leaflet": "^1.9.3",
1619
"@types/react": "^18.0.28",
1720
"@types/react-dom": "^18.0.11",
1821
"@vitejs/plugin-react": "^3.1.0",

src/app/src/App.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#root {
22
max-width: 1280px;
3+
max-height: 1wh;
34
margin: 0 auto;
45
padding: 2rem;
56
text-align: center;
@@ -40,3 +41,15 @@
4041
.read-the-docs {
4142
color: #888;
4243
}
44+
45+
.App {
46+
border: 1px solid green;
47+
width: 80%;
48+
height:50%;
49+
50+
}
51+
52+
.title {
53+
font-family: Arial Black,Arial Bold,Gadget,sans-serif;
54+
font-size: 4rem;
55+
}

src/app/src/App.tsx

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
1-
import { useState } from 'react'
2-
import reactLogo from './assets/react.svg'
3-
import viteLogo from '/vite.svg'
41
import './App.css'
2+
import Map from './Map/Map'
3+
4+
55

66
function App() {
7-
const [count, setCount] = useState(0)
87

98
return (
10-
<div className="App">
11-
<div>
12-
<a href="https://vitejs.dev" target="_blank">
13-
<img src={viteLogo} className="logo" alt="Vite logo" />
14-
</a>
15-
<a href="https://reactjs.org" target="_blank">
16-
<img src={reactLogo} className="logo react" alt="React logo" />
17-
</a>
18-
</div>
19-
<h1>Vite + React</h1>
20-
<div className="card">
21-
<button onClick={() => setCount((count) => count + 1)}>
22-
count is {count}
23-
</button>
24-
<p>
25-
Edit <code>src/App.tsx</code> and save to test HMR
26-
</p>
27-
</div>
28-
<p className="read-the-docs">
29-
Click on the Vite and React logos to learn more
30-
</p>
9+
<div>
10+
<div className="title">THIRD PLACES PROJECT</div>
11+
<Map/>
3112
</div>
13+
3214
)
3315
}
3416

35-
export default App
17+
export default App

src/app/src/Map/Map.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.leaflet-container {
2+
height: 700px;
3+
width: 700px;
4+
margin-left: auto;
5+
margin-right: auto;
6+
}

src/app/src/Map/Map.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import './Map.css'
2+
import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet'
3+
import 'leaflet/dist/leaflet.css'
4+
5+
6+
function Map() {
7+
8+
return (
9+
<div className="leaflet-container">
10+
<MapContainer center={[39.952584, -75.165222]} zoom={13} scrollWheelZoom={true}>
11+
<TileLayer
12+
attribution='&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
13+
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
14+
/>
15+
<Marker position={[39.952584, -75.165222]}>
16+
<Popup>
17+
This spots got a good vibe
18+
</Popup>
19+
</Marker>
20+
</MapContainer>
21+
</div>
22+
)
23+
}
24+
25+
export default Map

0 commit comments

Comments
 (0)