mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-04-21 12:16:59 +02:00
Fixing map's regexp matching issue: no need to use global as only one match is enough #647
This commit is contained in:
parent
68d09cec46
commit
04ce343d9f
@ -116,7 +116,7 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
|
|||||||
private pathLayersConfigOrdered = [
|
private pathLayersConfigOrdered = [
|
||||||
{
|
{
|
||||||
name: $localize`Transportation`,
|
name: $localize`Transportation`,
|
||||||
matchers: [/flight/gi, /flying/gi, /drive/gi, /driving/gi] as RegExp[],
|
matchers: [/flight/i, /flying/i, /drive/i, /driving/i] as RegExp[],
|
||||||
layer: layerGroup([]),
|
layer: layerGroup([]),
|
||||||
theme: {color: 'var(--bs-orange)', dashArray: '4 8'},
|
theme: {color: 'var(--bs-orange)', dashArray: '4 8'},
|
||||||
icon: null as DivIcon,
|
icon: null as DivIcon,
|
||||||
@ -127,7 +127,7 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: $localize`Sport`,
|
name: $localize`Sport`,
|
||||||
matchers: [/run/gi, /walk/gi, /hike/gi, /hiking/gi, /bike/gi, /biking/gi, /cycling/gi] as RegExp[],
|
matchers: [/run/i, /walk/i, /hike/i, /hiking/i, /bike/i, /biking/i, /cycling/i] as RegExp[],
|
||||||
layer: layerGroup([]),
|
layer: layerGroup([]),
|
||||||
theme: {color: 'var(--bs-primary)'},
|
theme: {color: 'var(--bs-primary)'},
|
||||||
svgIcon: {
|
svgIcon: {
|
||||||
@ -520,11 +520,13 @@ export class GalleryMapLightboxComponent implements OnChanges, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pathLayer = this.pathLayersConfigOrdered.find((pl) => {
|
const pathLayer = this.pathLayersConfigOrdered.find((pl) => {
|
||||||
|
console.log(pl.matchers,pl?.matchers?.findIndex(m => m.test(parsedGPX.name)) );
|
||||||
return pl.matchers === null || // null matchers match everything
|
return pl.matchers === null || // null matchers match everything
|
||||||
(parsedGPX.name &&
|
(parsedGPX.name &&
|
||||||
pl.matchers.findIndex(m => m.test(parsedGPX.name)) !== -1);
|
pl.matchers.findIndex(m => m.test(parsedGPX.name)) !== -1);
|
||||||
}) || this.pathLayersConfigOrdered[0];
|
}) || this.pathLayersConfigOrdered[0];
|
||||||
|
|
||||||
|
console.log(parsedGPX.name, pathLayer.theme.color);
|
||||||
if (parsedGPX.path.length !== 0) {
|
if (parsedGPX.path.length !== 0) {
|
||||||
// render the beginning of the path with a marker
|
// render the beginning of the path with a marker
|
||||||
const mkr = marker(parsedGPX.path[0]);
|
const mkr = marker(parsedGPX.path[0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user