@trailstash/ultra 3.2.1 → 3.2.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.
- package/components/ultra-map.js +4 -0
- package/lib/queryParams.js +13 -0
- package/package.json +1 -1
package/components/ultra-map.js
CHANGED
|
@@ -7,6 +7,7 @@ import { parseSettings } from "../lib/settings.js";
|
|
|
7
7
|
import queryProviders from "../lib/queryProviders/index.js";
|
|
8
8
|
import AutoProvider from "../lib/queryProviders/auto.js";
|
|
9
9
|
import {
|
|
10
|
+
hasHash,
|
|
10
11
|
getOptionsFromQueryParams,
|
|
11
12
|
getQueryFromQueryParams,
|
|
12
13
|
} from "../lib/queryParams.js";
|
|
@@ -160,6 +161,8 @@ export class UltraMap extends HTMLElement {
|
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
#initUnbound(mapStyle) {
|
|
164
|
+
const hadHash = hasHash(this.options.hash);
|
|
165
|
+
|
|
163
166
|
this.refs = {
|
|
164
167
|
mapLibre: h("map-libre", {
|
|
165
168
|
mapStyle,
|
|
@@ -187,6 +190,7 @@ export class UltraMap extends HTMLElement {
|
|
|
187
190
|
return this.#run().then((data) => {
|
|
188
191
|
if (
|
|
189
192
|
this.#fitBounds &&
|
|
193
|
+
(!this.options.hash || !hadHash) &&
|
|
190
194
|
!this.options.bounds &&
|
|
191
195
|
(this.options.zoom === undefined || !this.options.center)
|
|
192
196
|
) {
|
package/lib/queryParams.js
CHANGED
|
@@ -41,6 +41,19 @@ const fetchURL = async (url) => {
|
|
|
41
41
|
return await resp.text();
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
+
export const hasHash = (hashName) => {
|
|
45
|
+
let hash = window.location.hash.slice(1)
|
|
46
|
+
if (hashName) {
|
|
47
|
+
const params = new URLSearchParams(hash);
|
|
48
|
+
hash = params.get(hashName);
|
|
49
|
+
}
|
|
50
|
+
if (!hash) {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
const loc = hash.split("/");
|
|
54
|
+
return loc.length >= 3 && !loc.some(v => isNaN(v));
|
|
55
|
+
};
|
|
56
|
+
|
|
44
57
|
export const getQueryFromQueryParams = () => {
|
|
45
58
|
const params = new URLSearchParams(window.location.hash.slice(1));
|
|
46
59
|
|
package/package.json
CHANGED