Use API v4 and access tokens
This commit is contained in:
@@ -17,6 +17,12 @@
|
||||
|
||||
namespace llmr {
|
||||
|
||||
static std::string mapboxAccessToken;
|
||||
|
||||
void setMapboxAccessToken(const std::string& token) {
|
||||
mapboxAccessToken = token;
|
||||
}
|
||||
|
||||
Source::Source(SourceType type, const std::string &url,
|
||||
uint32_t tile_size, uint32_t min_zoom, uint32_t max_zoom)
|
||||
: type(type),
|
||||
@@ -28,7 +34,10 @@ Source::Source(SourceType type, const std::string &url,
|
||||
std::string Source::normalizeSourceURL(const std::string &url) {
|
||||
const std::string t = "mapbox://";
|
||||
if (url.compare(0, t.length(), t) == 0) {
|
||||
return std::string("http://api.tiles.mapbox.com/v3/") + url.substr(t.length()) + "/%d/%d/%d.vector.pbf";
|
||||
if (mapboxAccessToken.empty()) {
|
||||
throw std::runtime_error("You must provide a Mapbox API access token via llmr::setMapboxAccessToken()");
|
||||
}
|
||||
return std::string("https://api.tiles.mapbox.com/v4/") + url.substr(t.length()) + "/%d/%d/%d.vector.pbf?access_token=" + mapboxAccessToken;
|
||||
} else {
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user