Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid cached vector tiles from Mapbox

I'm running into a problem with Mapbox-GL-JS where there are cached vector tiles in my browser, preventing recent changes being seen. The normal workaround is to append a unique string onto the end of the tile string (example.com/tiles/1/2/3.png?update=1), but I'm not sure how to make that work in Mapbox-GL-JS, because it constructs the tile strings for me, from a composite of layers:

...
metadata": {
    "mapbox:autocomposite": true,
    "mapbox:type": "default"
  },
  "sources": {
    "mapbox": {
      "url": "mapbox://mapbox.satellite",
      "type": "raster",
      "tileSize": 256
    },
    "composite": {
      "url": "mapbox://stevage.9vj4wkw3,mapbox.mapbox-streets-v7,stevage.ab95cml8",
      "type": "vector"
    }
  },

Is there some way to force some extra text into the URL?

like image 892
Steve Bennett Avatar asked Jan 09 '17 21:01

Steve Bennett


People also ask

What is a tileset in Mapbox?

A tileset is a collection of raster or vector data broken up into a uniform grid of square tiles at up to 22 preset zoom levels. Tilesets are used in Mapbox libraries and SDKs as a core piece of making maps visible on mobile or in the browser; they are also the main mechanism we use for determining map views.

Is Mapbox completely free?

While Mapbox isn't entirely free, it has a generous free tier in its pricing packages that makes the service attractive for apps with a low volume of users. Free for up to 25,000 mobile users and 50,000 web loads. Customization of maps is easy.

Is Mapbox GL free?

Is Mapbox GL JS open source? The previous version, Mapbox GL JS v1, is indeed a free and open-source, BSD3 licensed software. Anyone can contribute to it, or start their own derived work based on it, for free.


1 Answers

Any query parameters at the end of a mapbox:// url will be preserved. You may find interesting the fresh parameter which we have special-cased to skip most API-side caches.

...
metadata": {
    "mapbox:autocomposite": true,
    "mapbox:type": "default"
  },
  "sources": {
    "mapbox": {
      "url": "mapbox://mapbox.satellite?fresh=true",
      "type": "raster",
      "tileSize": 256
    },
    "composite": {
      "url": "mapbox://stevage.9vj4wkw3,mapbox.mapbox-streets-v7,stevage.ab95cml8?fresh=true",
      "type": "vector"
    }
  },
like image 148
Lucas Wojciechowski Avatar answered Oct 05 '22 17:10

Lucas Wojciechowski