FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
google-map-react/example/src/App.js at develop · bkocoglu/google-map-react · GitHub
bkocoglu
/
google-map-react
Public
forked from
google-map-react/google-map-react
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
google-map-react
/
example
/
src
/
App.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (42 loc) · 1.05 KB
Breadcrumbs
google-map-react
/
example
/
src
/
App.js
Copy path
File metadata and controls
52 lines (42 loc) · 1.05 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
styled
from
'styled-components'
;
import
GoogleMapReact
from
'google-map-react'
// import 'google-map-react/dist/index.css'
import
{
LOS_ANGELES
}
from
'./const/cities'
;
import
Marker
from
'./components/Marker'
;
const
Wrapper
=
styled
.
main
`
width: 100%;
height: 100%;
`
;
const
App
=
(
)
=>
{
const
[
places
,
setPlaces
]
=
useState
(
[
]
)
const
fetchPlaces
=
async
(
)
=>
{
fetch
(
'places.json'
)
.
then
(
(
response
)
=>
response
.
json
(
)
)
.
then
(
(
data
)
=>
setPlaces
(
data
.
results
)
)
}
useEffect
(
(
)
=>
{
fetchPlaces
(
)
;
}
,
[
]
)
if
(
!
places
||
places
.
length
===
0
)
{
return
null
;
}
return
(
<
Wrapper
>
<
GoogleMapReact
defaultZoom
=
{
10
}
defaultCenter
=
{
LOS_ANGELES
}
>
{
places
.
map
(
(
place
)
=>
(
<
Marker
key
=
{
place
.
id
}
text
=
{
place
.
name
}
lat
=
{
place
.
geometry
.
location
.
lat
}
lng
=
{
place
.
geometry
.
location
.
lng
}
/>
)
)
}
</
GoogleMapReact
>
</
Wrapper
>
)
}
export
default
App
Back
|
FazBrowse Home
|
New Git URL