Skip to content

updating mapbox token #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 10, 2020
Merged

updating mapbox token #8

merged 10 commits into from
Jan 10, 2020

Conversation

jdamiba
Copy link
Contributor

@jdamiba jdamiba commented Jan 6, 2020

closes plotly/documentation#1647

The purpose of this PR is to use a new mapbox token with URL restrictions. As a bonus, existing references to the key in version control have been removed for environment variables in CircleCI.

@@ -164,14 +131,31 @@ p <- us_cities %>%
p
```

### Mapbox Access Tokens and When You Need Them
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this back up to the top plz

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to top.

remove mapbox token from ci

using correct attribute name for mapbox token

moving access token paragraph to top of mapbox-layers example

re-adding token to examples that need it
@jdamiba jdamiba force-pushed the update-mapbox-token branch from cfe8120 to 603b870 Compare January 7, 2020 17:00
mapboxToken <- paste(readLines("../.mapbox_token"), collapse="") # You need your own token

# Setting mapbox token for R environment
Sys.setenv("MAPBOX_TOKEN" = mapboxToken)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I'm pretty sure that either this Sys.setenv line or the config(accesstoken = mapboxToken) line are required but not both, just like in Javascript. Can you please update these docs to use one or the other and actually document this behaviour in the mapbox-layers file?

Copy link
Contributor Author

@jdamiba jdamiba Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From testing in my local dev environment, it seems like Sys.setenv is not a valid way of passing the token.

Edit: this turns out to be the case only if using the plot_mapbox() call signature instead of the plot_ly call signature.

<li> `layout.mapbox.layers` is an array that defines more layers that are by default rendered above the traces in `data` (although this can also be controlled via the `below` attribute).</li>
</ol>


### Mapbox Access Tokens and When You Need Them

The word "mapbox" in the trace names and `layout.mapbox` refers to the Mapbox.js open-source library. If your basemap in `layout.mapbox.style` uses data from the Mapbox *service*, then you will need to register for a free account at https://mapbox.com/ and obtain a Mapbox Access token. This token should be provided either in `mapboxAccessToken` in `setPlotConfig` function, or as a variable that would be passed as an argument of `newPlot`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph appears to be the one from the JS docs... newPlot isn't an R function and neither is setPlotConfig so let's change it to match the behaviour of the R library please, including the two ways of setting the token :)

@@ -42,10 +33,6 @@ library(plotly)
packageVersion('plotly')
```

### Mapbox Access Token

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these warning paragraphs should stay, even if the page doesn't include a map that requires a token, because some values of style require one.

```{r}
library(plotly)
packageVersion('plotly')
```

### Mapbox Access Token
### Mapbox Access Tokens and When You Need Them
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reference version of this paragraph should (and does?) live in the /r/mapbox-layers/ and should be linked to from here via the cut and paste "you may need a mapbox token" paragraph in some of the other pages.

@nicolaskruchten
Copy link
Contributor

CI is failing and there's a conflict atm

@jdamiba
Copy link
Contributor Author

jdamiba commented Jan 9, 2020

I got CI to pass again and resolved the conflict.


The word "mapbox" in the trace names and `layout.mapbox` refers to the Mapbox.js open-source library. If your basemap in `layout.mapbox.style` uses data from the Mapbox *service*, then you will need to register for a free account at https://mapbox.com/ and obtain a Mapbox Access token. This token should be provided either in `mapboxAccessToken` in `setPlotConfig` function, or as a variable that would be passed as an argument of `newPlot`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first two sentences here are important and were lost in the shuffle.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-added.


The map is composed of layers of three different types.
<ol>
<li> the `layout(mapbox(style))` call signature defines the lowest layers, also known as your "base map"</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block needs to move back up above the "Mapbox Access Tokens and When You Need Them" because this is where we introduce style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved back above.

<ol>
<li> the `layout(mapbox(style))` call signature defines the lowest layers, also known as your "base map"</li>
<li> The various traces in the `plot_ly` call signature are by default rendered above the base map (this can be controlled via the use of `below` attribute).</li>
<li> the `layout(mapbox(layers()))` call signature is an array that defines more layers that are by default rendered above the traces in `data` (although this can also be controlled via the `below` attribute).</li>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this usage of "call signature" doesn't make sense... A call signature is basically the name and layout of arguments you pass to a function, so you can't say it "is an array". You can say something like "when calling layout(mapbox(layers())) you need to pass in an array" or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.


Here is the same example, with in addition, a WMS layer from Environment Canada which displays near-real-time radar imagery in partly-transparent raster tiles, rendered above the `go.Scattermapbox` trace, as is the default:
This example uses the same basemap as the one above. However, in this case, partly-transparent raster tiles are rendered above the trace as well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change loses the explanation of what the top layer is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-added specifics about top layer.

@nicolaskruchten
Copy link
Contributor

OK let's ship this thing. 💃

@jdamiba jdamiba merged commit e1f8ec9 into master Jan 10, 2020
@jdamiba jdamiba deleted the update-mapbox-token branch January 10, 2020 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mapbox token
2 participants