@trailstash/ultra 3.5.0 → 3.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,7 @@ export class UltraMap extends HTMLElement {
30
30
  #init;
31
31
  #shadow;
32
32
 
33
+ #cachedBBox;
33
34
  #cachedType;
34
35
  #cachedQuery;
35
36
  #cachedSource;
@@ -124,7 +125,7 @@ export class UltraMap extends HTMLElement {
124
125
  this.#shadow.adoptedStyleSheets.push(css);
125
126
 
126
127
  if (this.loadSettingsFromQueryParams) {
127
- return Promise.resolve(getQueryFromQueryParams() || config.query).then(
128
+ return Promise.resolve(getQueryFromQueryParams() || this.query).then(
128
129
  async (query) => {
129
130
  const querySettings = parseSettings(query);
130
131
  const settings = {
@@ -263,8 +264,12 @@ export class UltraMap extends HTMLElement {
263
264
  if (
264
265
  !this.#cachedSource ||
265
266
  this.type !== this.#cachedType ||
266
- query !== this.#cachedQuery
267
+ query !== this.#cachedQuery ||
268
+ (queryProvider.invalidateCacheOnBBox &&
269
+ this.#cachedBBox !=
270
+ setQueryBounds("{{bbox}}", this.refs.mapLibre.bounds))
267
271
  ) {
272
+ this.#cachedBBox = setQueryBounds("{{bbox}}", this.refs.mapLibre.bounds);
268
273
  this.#cachedQuery = query;
269
274
  this.#cachedType = this.type;
270
275
  this.#cachedSource = await queryProvider.source(query, controller, {
@@ -3,6 +3,7 @@ export default class AutoProvider {
3
3
  #layers;
4
4
  #popupContextBuilder;
5
5
  #popupTemplate;
6
+ #invalidateCacheOnBBox;
6
7
  #providers;
7
8
 
8
9
  constructor(providers = {}) {
@@ -23,6 +24,7 @@ export default class AutoProvider {
23
24
  this.#layers = provider.layers;
24
25
  this.#popupContextBuilder = provider.popupContextBuilder;
25
26
  this.#popupTemplate = provider.popupTemplate;
27
+ this.#invalidateCacheOnBBox = provider.invalidateCacheOnBBox;
26
28
  return provider.source(query, controller, { server, bounds });
27
29
  }
28
30
  }
@@ -44,4 +46,16 @@ export default class AutoProvider {
44
46
  get popupTemplate() {
45
47
  return this.#popupTemplate;
46
48
  }
49
+
50
+ get popupTemplate() {
51
+ return this.#popupTemplate;
52
+ }
53
+
54
+ get invalidateCacheOnBBox() {
55
+ // This isn't ideal, because this is called _before_ `source`, but it will work because it's either:
56
+ // * undefined & the first run, so bc first run it always will execute anyway
57
+ // * different type, which might mean a different invalidateCacheOnBBox value, but we always run on new type anyway
58
+ // * type unchanged, & subsequent run, so actually valid value
59
+ return this.#invalidateCacheOnBBox;
60
+ }
47
61
  }
@@ -58,5 +58,6 @@ const overpass = {
58
58
  layers,
59
59
  popupTemplate,
60
60
  popupContextBuilder,
61
+ invalidateCacheOnBBox: true,
61
62
  };
62
63
  export default overpass;
@@ -126,6 +126,7 @@ export const osmWebsite = {
126
126
  return !!query.match(osmUrlRe);
127
127
  },
128
128
  fitBounds: true,
129
+ invalidateCacheOnBBox: true,
129
130
  };
130
131
 
131
132
  export const osmWiki = {
@@ -165,4 +166,5 @@ out geom;`,
165
166
  const page = decodeURIComponent(url.pathname.slice(6));
166
167
  return page.split(":")[0] === "Tag" || page.split(":")[0] === "Key";
167
168
  },
169
+ invalidateCacheOnBBox: true,
168
170
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.5.0",
6
+ "version": "3.5.2",
7
7
  "description": "A web based tool for making MapLibre GL maps with data from sources such as Overpass, GeoJSON, GPX, KML, TCX, etc",
8
8
  "main": "index.js",
9
9
  "scripts": {