Vector Tiles: Set Access Token in 4.0 beta 3?

2967
6
Jump to solution
01-08-2016 05:10 AM
DavidChrest
Occasional Contributor II

In 3.15, you can use third party Vector Tiles by setting the Access Token like this:

VectorTileLayer.ACCESS_TOKEN = " ";
 
var vectorTileLayer = new VectorTileLayer("mapbox://styles/mapbox/streets-v8");

Is there a way to do this in 4.0 beta 3? There seems to be no mention of using an Access Token in the API documentation. For now, are we only able to use the listed Esri Vector Tile URLs (World Base Map and 8 JSON style objects) in the documentation?

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Frequent Contributor

Ok, this works in 4.0beta3

   

var tileLyr = new VectorTileLayer({
  ACCESS_TOKEN: "YOUR_KEY",
  url: "mapbox://styles/mapbox/streets-v8"
});

View solution in original post

6 Replies
ReneRubalcava
Frequent Contributor

I think it should work if you add the token to the URL.

0 Kudos
DavidChrest
Occasional Contributor II

I tried that but it doesn't seem to work that simple. I am not sure of the exact syntax betwee "...streets-v8" and my long access token string. I tried a couple things but nothing worked.

0 Kudos
ReneRubalcava
Frequent Contributor

Ok, this works in 4.0beta3

   

var tileLyr = new VectorTileLayer({
  ACCESS_TOKEN: "YOUR_KEY",
  url: "mapbox://styles/mapbox/streets-v8"
});
DavidChrest
Occasional Contributor II

Fantastic! Works great now. Makes sense, was just a matter of 4.0's syntax. Thank you so very much!

By the way, congrats on the move to Esri.

I have and love your book ArcGIS Web Devlopment. Looking forward to the 4.0 book. Like the format you planed: in-depth coverage of new aspects with multiple samples.

I'll miss your GeoNet blog but will remain a loyal fan of your other blog: odoenet - programming geo . Has been a huge help.

Thanks again for your quick fix and response.

David

KristianEkenes
Esri Regular Contributor

FYI, in the final (non-beta) release of 4.0, the ACCESS_TOKEN property will be treated similar to the way it is in 3.15. You will no longer be able to do this:

//This only works in 4.0 beta 3
var tileLyr = new VectorTileLayer({
  ACCESS_TOKEN: "YOUR_KEY",
  url: "mapbox://styles/mapbox/streets-v8"
});

Instead, this will be the correct way to accomplish this:

//This is how you set the access token in 4.0 final
VectorTileLayer.ACCESS_TOKEN = "YOUR_KEY";
var tileLyr = new VectorTileLayer({
  url: "mapbox://styles/mapbox/streets-v8"
});

DavidChrest
Occasional Contributor II

Great! Thank so much Kristian for letting me know. This is quite handy information I'll be using when non-beta 4.0 is released.

0 Kudos