Skip to content

Commit e1f8ec9

Browse files
author
Joseph Damiba
authored
Merge pull request #8 from plotly/update-mapbox-token
updating mapbox token
2 parents 16b2933 + 99fabef commit e1f8ec9

11 files changed

+101
-147
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
- run:
4040
name: build site and perform front-matter checks
4141
command: |
42+
echo ${mapbox_token} > .mapbox_token
4243
rm -rf build
4344
mkdir build
4445
mkdir build/ggplot2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Session Data files
66
.RData
77

8+
#mapbox dev token
9+
.mapbox_token
10+
811
# Example code in package build process
912
*-Ex.R
1013

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Imports:
2222
forcats,
2323
ggplot2,
2424
haven,
25+
listviewer,
2526
hms,
2627
httr,
2728
jsonlite,

r/2017-01-19-buttons.Rmd

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ output:
1717
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
1818
```
1919

20-
```{r, echo = FALSE}
21-
# Mapbox token for plotly | this one is for plot_mapbox figure
22-
mapboxToken <- paste("pk.eyJ1IjoicGxvdGx5bWFwYm94IiwiYSI6ImNqdnBvNDMyaT",
23-
"AxYzkzeW5ubWdpZ2VjbmMifQ.TXcBE-xg9BFdV2ocecc_7g", sep = "")
24-
25-
# Setting mapbox token for R environment
26-
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
27-
```
28-
2920
### New to Plotly?
3021

3122
Plotly's R library is free and open source!<br>
@@ -336,11 +327,17 @@ Animations are currently only available in the [development package](https://plo
336327

337328
When adding buttons to Plotly charts, users have the option of styling the color, font, padding, and position of the buttons. The example below demostrates hot to apply different styling options. See all updatemenus styling attributes here: https://plot.ly/r/reference/#layout-updatemenus.
338329

330+
#### Mapbox Access Token
331+
332+
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/r/mapbox-layers/) documentation for more information. If you're using a Chart Studio Enterprise server, please see additional instructions [here](https://help.plot.ly/mapbox-atlas).
333+
339334
```{r}
340335
library(plotly)
341336
342-
# make sure you have a Mapbox token https://www.mapbox.com/help/create-api-access-token/
343-
# Sys.setenv('MAPBOX_TOKEN' = 'your mapbox token')
337+
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token
338+
339+
# Setting mapbox token for R environment
340+
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
344341
345342
# read in wind turbines and farms data
346343
df_wind = read.csv('data/2805.csv')
@@ -426,8 +423,8 @@ p <- plot_mapbox(df_sub, lat = ~lat_DD, lon = ~long_DD, mode = 'scattermapbox',
426423
yanchor = "bottom",
427424
x = 1,
428425
y = 0,
429-
buttons=list(dark,basic,satellite))))
430-
426+
buttons=list(dark,basic,satellite)))) %>%
427+
config(mapboxAccessToken = Sys.getenv("MAPBOX_TOKEN"))
431428
432429
p
433430
```

r/2017-02-27-scattermapbox.Rmd

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ thumbnail: thumbnail/scatter-mapbox.jpg
1717
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
1818
```
1919

20-
```{r, echo = FALSE}
21-
# Mapbox token for plotly | this one is for plot_mapbox figure
22-
mapboxToken <- paste("pk.eyJ1IjoicGxvdGx5bWFwYm94IiwiYSI6ImNqdnBvNDMyaT",
23-
"AxYzkzeW5ubWdpZ2VjbmMifQ.TXcBE-xg9BFdV2ocecc_7g", sep = "")
24-
25-
# Setting mapbox token for R environment
26-
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
27-
```
28-
2920
### New to Plotly?
3021

3122
Plotly's R library is free and open source!<br>
@@ -37,25 +28,25 @@ We also have a quick-reference [cheatsheet](https://images.plot.ly/plotly-docume
3728

3829
Version 4 of Plotly's R package is now [available](https://plot.ly/r/getting-started/#installation)!<br>
3930
Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-above/) for more information on breaking changes and new features available in this version.
31+
4032
```{r}
4133
library(plotly)
4234
packageVersion('plotly')
4335
```
4436

4537
### Mapbox Access Token
4638

47-
To create mapbox maps with Plotly, you'll need a Mapbox account and a [Mapbox Access Token](https://www.mapbox.com/studio/) that you can add to your [Plotly Settings](https://plot.ly/settings/mapbox). If you're using a Chart Studio Enterprise server, please see additional instructions here: https://help.plot.ly/mapbox-atlas/.
48-
49-
```{r}
50-
library(plotly)
51-
packageVersion('plotly')
52-
```
39+
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/r/mapbox-layers/) documentation for more information. If you're using a Chart Studio Enterprise server, please see additional instructions [here](https://help.plot.ly/mapbox-atlas).
5340

5441
### Basic Example
5542

5643
```{r}
5744
library(plotly)
5845
46+
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token
47+
Sys.setenv("MAPBOX_TOKEN" = mapboxToken) # for Orca
48+
49+
5950
dat <- map_data("world", "canada") %>% group_by(group)
6051
6152
p <- plot_mapbox(dat, x = ~long, y = ~lat) %>%
@@ -64,7 +55,8 @@ p <- plot_mapbox(dat, x = ~long, y = ~lat) %>%
6455
layout(mapbox = list(zoom = 0,
6556
center = list(lat = ~median(lat),
6657
lon = ~median(long))
67-
))
58+
)) %>%
59+
config(mapboxAccessToken = Sys.getenv("MAPBOX_TOKEN"))
6860
6961
p
7062
```
@@ -74,6 +66,9 @@ p
7466
```{r}
7567
library(plotly)
7668
69+
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token
70+
Sys.setenv("MAPBOX_TOKEN" = mapboxToken) # for Orca
71+
7772
df = read.csv('https://raw.githubusercontent.com/bcdunbar/datasets/master/meteorites_subset.csv')
7873
7974
p <- df %>%
@@ -88,7 +83,8 @@ p <- df %>%
8883
font = list(size = 8)),
8984
margin = list(l = 25, r = 25,
9085
b = 25, t = 25,
91-
pad = 2))
86+
pad = 2)) %>%
87+
config(mapboxAccessToken = Sys.getenv("MAPBOX_TOKEN"))
9288
9389
p
9490
```
@@ -99,6 +95,9 @@ p
9995
library(plotly)
10096
library(dplyr)
10197
98+
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token
99+
Sys.setenv("MAPBOX_TOKEN" = mapboxToken) # for Orca
100+
102101
# airport locations
103102
air <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_us_airport_traffic.csv')
104103
@@ -125,7 +124,8 @@ p <- plot_mapbox(mode = 'scattermapbox') %>%
125124
margin = list(l = 0, r = 0,
126125
b = 0, t = 0,
127126
pad = 0),
128-
showlegend=FALSE)
127+
showlegend=FALSE) %>%
128+
config(mapboxAccessToken = Sys.getenv("MAPBOX_TOKEN"))
129129
130130
p
131131
```

r/2017-04-12-county-level-choropleth.Rmd

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ thumbnail: thumbnail/county-level-choropleth.jpg
1616
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
1717
```
1818

19-
```{r, echo = FALSE}
20-
# Mapbox token for plotly | this one is for plot_mapbox figure
21-
mapboxToken <- paste("pk.eyJ1IjoicGxvdGx5bWFwYm94IiwiYSI6ImNqdnBvNDMyaT",
22-
"AxYzkzeW5ubWdpZ2VjbmMifQ.TXcBE-xg9BFdV2ocecc_7g", sep = "")
23-
24-
# Setting mapbox token for R environment
25-
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
26-
```
27-
2819
### New to Plotly?
2920

3021
Plotly's R library is free and open source!<br>
@@ -43,7 +34,7 @@ packageVersion('plotly')
4334

4435
### Mapbox Access Token
4536

46-
To create mapbox maps with Plotly, you'll need a Mapbox account and a [Mapbox Access Token](https://www.mapbox.com/studio/) that you can add to your [Plotly Settings](https://plot.ly/settings/mapbox). If you're using a Chart Studio Enterprise server, please see additional instructions here: https://help.plot.ly/mapbox-atlas/.
37+
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/r/mapbox-layers/) documentation for more information. If you're using a Chart Studio Enterprise server, please see additional instructions [here](https://help.plot.ly/mapbox-atlas).
4738

4839
### Creating Polygon Boundaries
4940

@@ -147,19 +138,12 @@ p
147138
```
148139

149140
### Add Polygon to Mapbox
150-
151-
To create mapbox maps with Plotly, you'll need a Mapbox account and a [Mapbox Access Token](https://www.mapbox.com/studio/) that you can add to your [Plotly Settings](https://plot.ly/settings/mapbox).
152-
153-
```{r, results = 'hide'}
154-
library(plotly)
155-
156-
Sys.setenv('MAPBOX_TOKEN' = 'your_mapbox_token_here')
157-
```
158-
159-
160141
```{r}
161142
library(plotly)
162143
144+
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token
145+
Sys.setenv("MAPBOX_TOKEN" = mapboxToken) # for Orca
146+
163147
p <- cali_pop %>%
164148
group_by(group) %>%
165149
plot_mapbox(x = ~long, y = ~lat, color = ~pop_cat, colors = c('#ffeda0','#f03b20'),
@@ -179,7 +163,8 @@ p <- cali_pop %>%
179163
zoom = 4,
180164
center = list(lat = ~median(lat), lon = ~median(long))),
181165
margin = list(l = 0, r = 0, b = 0, t = 0, pad = 0)
182-
)
166+
) %>%
167+
config(mapboxAccessToken = Sys.getenv("MAPBOX_TOKEN"))
183168
184169
p
185170
```

r/2018-06-22-sf.Rmd

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ thumbnail: thumbnail/sf.jpg
1616
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
1717
```
1818

19-
```{r, echo = FALSE}
20-
# Mapbox token for plotly | this one is for plot_mapbox figure
21-
mapboxToken <- paste("pk.eyJ1IjoicGxvdGx5bWFwYm94IiwiYSI6ImNqdnBvNDMyaT",
22-
"AxYzkzeW5ubWdpZ2VjbmMifQ.TXcBE-xg9BFdV2ocecc_7g", sep = "")
23-
24-
# Setting mapbox token for R environment
25-
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
26-
```
27-
2819
### New to Plotly?
2920

3021
Plotly's R library is free and open source!<br>
@@ -49,7 +40,11 @@ In order to complete the examples below, you'll require installing additional pa
4940

5041
The examples below use the library [simple features](https://r-spatial.github.io/sf/) to read in the shape files before plotting the features with Plotly.
5142

52-
### Basic sf
43+
### Mapbox Access Token
44+
45+
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/r/mapbox-layers/) documentation for more information. If you're using a Chart Studio Enterprise server, please see additional instructions [here](https://help.plot.ly/mapbox-atlas).
46+
47+
### Basic sf
5348

5449
``` {r}
5550
library(plotly)
@@ -81,14 +76,18 @@ Or `plot_mapbox`:
8176
library(plotly)
8277
library(sf)
8378
79+
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token
80+
Sys.setenv("MAPBOX_TOKEN" = mapboxToken) # for Orca
81+
8482
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
8583
8684
p <- plot_mapbox(nc, split=~NAME) %>%
8785
layout(
8886
mapbox = list(
8987
zoom = 6
9088
)
91-
)
89+
) %>%
90+
config(mapboxAccessToken = Sys.getenv("MAPBOX_TOKEN"))
9291
9392
p
9493
```

r/2019-09-20-filled-area-on-mapbox.Rmd

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,6 @@ thumbnail: thumbnail/area.jpg
1717
knitr::opts_chunk$set(message = FALSE, warning=FALSE)
1818
```
1919

20-
```{r, echo = FALSE}
21-
# Mapbox token for plotly | this one is for plot_mapbox figure
22-
mapboxToken <- paste("pk.eyJ1IjoicGxvdGx5bWFwYm94IiwiYSI6ImNqdnBvNDMyaT",
23-
"AxYzkzeW5ubWdpZ2VjbmMifQ.TXcBE-xg9BFdV2ocecc_7g", sep = "")
24-
25-
# Setting mapbox token for R environment
26-
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
27-
```
28-
2920
### New to Plotly?
3021

3122
Plotly's R library is free and open source!<br>
@@ -41,10 +32,9 @@ Check out [this post](http://moderndata.plot.ly/upgrading-to-plotly-4-0-and-abov
4132
library(plotly)
4233
packageVersion('plotly')
4334
```
44-
4535
### Mapbox Access Token
4636

47-
To plot on Mapbox maps with Plotly you `may` need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio), that you can add to your [Plotly Settings](https://plot.ly/settings/mapbox). See our [Mapbox Map Layers](/python/mapbox-layers/) documentation for more information. If you're using a Chart Studio Enterprise server, please see additional instructions [here](https://help.plot.ly/mapbox-atlas).
37+
To plot on Mapbox maps with Plotly you *may* need a Mapbox account and a public [Mapbox Access Token](https://www.mapbox.com/studio). See our [Mapbox Map Layers](/r/mapbox-layers/) documentation for more information. If you're using a Chart Studio Enterprise server, please see additional instructions [here](https://help.plot.ly/mapbox-atlas).
4838

4939
### How to Show an Area on a Map
5040

@@ -54,7 +44,8 @@ There are three different ways to show an area in a mapbox:
5444
<li> Use [Scattermapbox](https://plot.ly/r/reference/#scattermapbox) trace and define the corresponding geojson</li>
5545
<li> Use the new trace type: [Choroplethmapbox](https://plot.ly/r/mapbox-county-choropleth/) for mapbox cases, or [Choropleth](https://plot.ly/r/choropleth-maps/) trace for non-mapbox ones.</li>
5646
</ol>
57-
The following example uses `Scattermapbox` and sets `fill = 'toself'`
47+
48+
The following example uses the `Scattermapbox` trace and sets `fill = 'toself'`
5849

5950
```{r}
6051
library(plotly)
@@ -102,7 +93,7 @@ p
10293

10394
### Use the Corresponding Geojson
10495

105-
The second way is using Scattermapbox trace with the corresponding geojson.
96+
The second way is using the `scattermapbox` trace with the corresponding geojson.
10697

10798
```{r}
10899
library(plotly)

0 commit comments

Comments
 (0)