Platform
Resources
Pricing
Sign in
Get started
quintincutts
Workspace
Fork
Published
By
quintincutts
Edited
Mar 18, 2018
2 forks
5 stars
Insert cell
Insert cell
// This embeds my key. Get your own key - this one will be cycled out very soon!
google
=
require
(
'https://maps.googleapis.com/maps/api/js?key=AIzaSyB4JQkUKSUqHQmteJ5xdk4RdrFqHi04hdg'
)
.
catch
(
(
)
=>
window
.
google
)
Insert cell
Insert cell
mapHolder
=
[
0
]
Insert cell
Insert cell
{
let
div
=
html
`<div style='height:400px;'></div>`
;
// Like Leaflet and Mapbox GL JS, Google Maps is very picky about
// needing to be initialized on a div that's already included
// in the page. So I yield the div first, to establish it in
// the page.
yield
div
;
let
map
=
new
google
.
maps
.
Map
(
div
,
{
center
:
{
lng
:
-
4.291884
,
lat
:
55.874113
}
,
zoom
:
15
}
)
;
mapHolder
[
0
]
=
map
}
Insert cell
Insert cell
marker
=
new
google
.
maps
.
Marker
(
{
position
:
{
lng
:
-
4.291884
,
lat
:
55.874113
}
,
map
:
mapHolder
[
0
]
}
)
Insert cell
Insert cell
Insert cell
points
=
[
{
x
:
-
4.291884
,
y
:
55.874113
}
,
{
x
:
-
4.291000
,
y
:
55.874113
}
,
{
x
:
-
4.290000
,
y
:
55.874113
}
,
{
x
:
-
4.289000
,
y
:
55.874113
}
,
]
Insert cell
Insert cell
points
.
map
(
p
=>
new
google
.
maps
.
Marker
(
{
position
:
{
lng
:
p
.
x
,
lat
:
p
.
y
}
,
map
:
mapHolder
[
0
]
}
)
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
google
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
mapHolder
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
marker
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
points
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML