This repository has been archived by the owner on Nov 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.Rmd
55 lines (41 loc) · 1.57 KB
/
README.Rmd
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
53
54
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# So... what's going on here?
Yeah, I know, [mapdeck](https://github.com/SymbolixAU/mapdeck) already uses Mapbox! But, it's not straight forward controlling the underlying map, like setting `maxBounds` (as requested in this [issue](https://github.com/SymbolixAU/mapdeck/issues/41)), because the map object isn't a standard Mapbox `map` object.
For those of you interested, the map is defined in the `Deck` constructor
```js
const deckgl = new deck.DeckGL({
mapboxApiAccessToken: x.access_token,
container: el.id,
mapStyle: x.style,
layers: [],
});
```
Fortunately, Deck.gl also gives us a [Mapbox Layer](https://github.com/uber/deck.gl/blob/master/docs/api-reference/mapbox/mapbox-layer.md), which lets you use the Deck.gl layers on top of a standard Mapbox `map` object.
For example
```js
const map = new mapboxgl.Map({...});
const myScatterplotLayer = new MapboxLayer({
id: 'my-scatterplot',
type: ScatterplotLayer,
data: [
{position: [-74.5, 40], size: 100}
],
getPosition: d => d.position,
getRadius: d => d.size,
getColor: [255, 0, 0]
});
// add to mapbox
map.addLayer(myScatterplotLayer);
```
So this package will give you the 'standard' Mapbox map, and I'm updating [mapdeck](https://github.com/SymbolixAU/mapdeck) so it will accept this Mapbox map object and add the layers accordingly.